Question by
mpmlopes · Jan 20, 2018 at 10:03 PM ·
movementrotate object
Update heading based on rotation
I'm trying to change the heading of my player object based on the rotation. I can make the object rotate, but the heading stays the same.
void FixedUpdate () {
float moveHorizontal = Input.GetAxisRaw("Horizontal");
movement.Set (1f, 0f, 0f);
movement = movement.normalized * speed * Time.deltaTime;
body.MoveRotation (Quaternion.Euler (0.0f, moveHorizontal * rotationFactor, 0.0f));
body.MovePosition (transform.position + (transform.forward * movement.x));
}
if Instead of body.MoveRotation I do transform.rotation, then the object rotates, but the movement stops while rotating.
What's the correct way to change the heading of an object based on its rotation?
Thanks
Comment
Your answer