Version: 5.4 (switch to 5.5b)
言語English
  • C#
  • JS

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

CharacterController.SimpleMove

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

マニュアルに切り替える
public function SimpleMove(speed: Vector3): bool;
public bool SimpleMove(Vector3 speed);

Parameters

Description

キャラクターを speed 付きで動かします。

Y 軸に沿った速度は無視されます。 スピードは「メートル/秒」です。重力は自動的に適用されます。 キャラクターが接地しているかどうかを返します。 これは 1 フレームごとに Move や SimpleMove を呼び出すためだけに使用することをお勧めします。

	var speed : float = 3.0;
	var rotateSpeed : float = 3.0;

function Update () { var controller : CharacterController = GetComponent.<CharacterController>();

// Rotate around y - axis transform.Rotate(0, Input.GetAxis ("Horizontal") * rotateSpeed, 0); // Move forward / backward var forward : Vector3 = transform.TransformDirection(Vector3.forward); var curSpeed : float = speed * Input.GetAxis ("Vertical"); controller.SimpleMove(forward * curSpeed); }

@script RequireComponent(CharacterController)
using UnityEngine;
using System.Collections;

[RequireComponent(typeof(CharacterController))] public class ExampleClass : MonoBehaviour { public float speed = 3.0F; public float rotateSpeed = 3.0F; void Update() { CharacterController controller = GetComponent<CharacterController>(); transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed, 0); Vector3 forward = transform.TransformDirection(Vector3.forward); float curSpeed = speed * Input.GetAxis("Vertical"); controller.SimpleMove(forward * curSpeed); } }