移动:

  1、SimpleMove(Vector3: vector3&speed)

    简单移动,可以根据vector3方向移动,物体不需要添加刚体即受重力影响,不需要添加碰撞器即可以产生碰撞,但无法推动其它物体。

  2、Move(Vector3: vector3&speed)

    移动,根据vector3方向移动,速度比SimpleMove快许多,不受重力影响,但可以在不添加碰撞器的情况下产生碰撞,无法推动其它物体。

sample

using UnityEngine;
using System.Collections;

public class CharControl : MonoBehaviour {

    CharacterController charCtl ;
    // Use this for initialization
    void Start () {
        charCtl = GetComponent<CharacterController>() ;
    }
    
    // Update is called once per frame
    void Update () {
        charCtl.Move(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"))* 0.5f) ;
//        charCtl.SimpleMove(new Vector3(Input.GetAxis("Horizontal"), 0, Input.GetAxis("Vertical"))* 10) ;
    }
}
View Code

相关文章:

  • 2021-12-18
  • 2021-10-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-12
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案