- Home /
 
 
               Question by 
               zwoxy · Mar 22, 2014 at 01:42 PM · 
                rigidbodyvelocitylocal axistransformdirection  
              
 
              the velocity of a certain direction
I'm currently wrking on a project where I need the velocity of an object in the local z axis as a float. I tried transform.InverseTransformDirection(Vector3.forward).z * rigidbody.velocity.magnitude, but it keeps giving me the velocity in the global z axis. Anyone know how to fix this?
               Comment
              
 
               
              Answer by robertbu · Mar 22, 2014 at 02:20 PM
How about:
 var localZ : float = transform.InverseTransformDirection(rigidbody.velocity).z;
 
              Your answer