言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

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

Switch to Manual
public function SimpleMove(speed: Vector3): bool;
public bool SimpleMove(Vector3 speed);
public def SimpleMove(speed as Vector3) as bool

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);
    }
}
import UnityEngine
import System.Collections

[RequireComponent(typeof(CharacterController))]
public class ExampleClass(MonoBehaviour):

	public speed as float = 3.0F

	public rotateSpeed as float = 3.0F

	def Update() as void:
		controller as CharacterController = GetComponent[of CharacterController]()
		transform.Rotate(0, (Input.GetAxis('Horizontal') * rotateSpeed), 0)
		forward as Vector3 = transform.TransformDirection(Vector3.forward)
		curSpeed as float = (speed * Input.GetAxis('Vertical'))
		controller.SimpleMove((forward * curSpeed))