Version: 2020.2
言語: 日本語
public bool SimpleMove (Vector3 speed);

説明

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

Velocity along the y-axis is ignored. Speed is in units/s. Gravity is automatically applied. Returns if the character is grounded. It is recommended that you make only one call to Move or SimpleMove per frame.

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>();

// Rotate around y - axis transform.Rotate(0, Input.GetAxis("Horizontal") * rotateSpeed, 0);

// Move forward / backward Vector3 forward = transform.TransformDirection(Vector3.forward); float curSpeed = speed * Input.GetAxis("Vertical"); controller.SimpleMove(forward * curSpeed); } }
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961