A point in a direction in 3d

Hi,

The basic problem is that I want to set the rigidbody’s velocity be moving the direction that it is currently facing. Easier said than done. I looked in the Vector3 and Quaternion references but have not found any function that would allow me to do this. I have though I might use the Euler angles of the rotation and the magnitude of the velocity, be have not been able to find the formula to do this (basically cast a line with a distance in a certain direction, and find the end point). Any help would be greatly appreciated!

Connor

Sorry, I had something here, but it would only work for the x and z axis =(

rigidbody.velocity = transform.forward * speed;

transform.forward is the Local space Z axis, you may need to use .right or .up.
You may need to pretty this up to take into account more than just this simple demo, but that will at least set velocity to be the same as the direction of the player.

Thanks Ntero!