物体移动
- 使用 rigidbody.velocity 移动
- 使用 rigidbody.angularVelocity 旋转
private Rigidbody rigidbody;
// Start is called before the first frame update
void Start()
{
rigidbody = this.GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
float v = Input.GetAxis("Vertical");
float h = Input.GetAxis("Horizontal");
rigidbody.velocity = transform.forward * v * speed;
rigidbody.angularVelocity = transform.up * h * angularSpeed;
}