- Home /
Question by
anthonyjreavis · Oct 25, 2016 at 05:11 PM ·
rotationtransformvector3quaternions
How can I turn my cube object to the direction it is traveling?
I have tried many different options with Quaternions and what not, but all I want is for my cube to face the way it is sliding. It can't be this hard...
This is the move function I have in place:
private void FixedUpdate () { // Adjust the rigidbodies position and orientation in FixedUpdate. Move ();
}
private void Move()
{
// Move the character with vectors
Vector3 movement = transform.forward * cube_VerticalMovement * cube_Speed *Time.deltaTime;
Vector3 movement2 = transform.right * cube_HorizontalMovement * cube_Speed *Time.deltaTime;
Vector3 MoveVector = movement + movement2;
cube_Rigidbody.MovePosition (cube_Rigidbody.position + MoveVector);
// Turn the character in the direction of movement
}
Comment
Answer by anthonyjreavis · Oct 26, 2016 at 05:46 AM
Thanks. I did that and it set the forward vector into the ground for some reason.This in turn kills the movement code I have in place. Still working on it.
untitled1.png
(273.2 kB)
untitled2.png
(270.6 kB)