Pointing Navigation in Unity
void FixedUpdate(){
float x = 0, y = 0, z = 0;
float moveButton = moveAction.action.ReadValue<float>();
if (moveButton > 0)
{
if (xMovement)
x = hand.transform.forward.x;
if (yMovement)
y = hand.transform.forward.y;
if (zMovement)
z = hand.transform.forward.z;
Vector3 moveDirection = new Vector3(x, y, z);
rb.AddForce(moveDirection * moveSpeed,
ForceMode.VelocityChange);
rb.transform.rotation = Quaternion.Lerp(rb.transform.rotation,
Quaternion.LookRotation(moveDirection),
rotateSpeed * Time.fixedDeltaTime);
}
}
}