- Home /
Get direction of moving sphere?
Been at this for a while now, google-fu is letting me down.
I have a sphere (player) whose rigidbody is being moved by adding force, causing it to rotate (like pushing a marble). The player will be spawning platforms in a 3D space to climb higher and higher, so the platform needs to be spawned above and offset the position of the sphere.
Is there a simple way to get the "forward" direction of a rigidbody whose rotation and velocity are in constant change? I would like the direction the player is currently moving to spawn the platform at a set distance from the players current position, in the player's current direction, with a static Y value. I don't intent for the player to have an "aim" control outside of the movement control so using the right analog or mouse w/radius clamp would be out of the question.
For clarification, I have all aspects of this goal working, I just can't get a consistent and working position.
Answer by fafase · Mar 23, 2015 at 07:37 PM
rigidbody.velocity;
is the vector3 indicating the direction in which the rigidbody is going. This is in world space so it is regardless the rotation. For instance, if you go to the right but facing left, the velocity is 1,0,0 while the forward is -1,0,0