例如,通过按键/摇杆来操作飞机在三维空间的飞行状态。包括速度(大小,方向)、位移。

public class ExampleClass : MonoBehaviour {
    public float speed = 10.0F;
    public float rotationSpeed = 100.0F;
    void Update() {
        float translation = Input.GetAxis("Vertical") * speed;
        float rotation = Input.GetAxis("Horizontal") * rotationSpeed;
        translation *= Time.deltaTime;
        rotation *= Time.deltaTime;
        transform.Translate(0, 0, translation);
        transform.Rotate(0, rotation, 0);
    }
}

 

相关文章:

  • 2021-11-13
  • 2022-12-23
  • 2023-02-08
  • 2021-11-22
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-22
  • 2021-11-25
相关资源
相似解决方案