- Home /
Question by
Timurov · Dec 17, 2012 at 02:33 PM ·
c#directionspherecast
How to get direction using Physics.SphereCast ?
The question is very simple, but it makes me mad, just need to get the direction for game object which is under character controller. Is there any example to illustrate how to get the direction?
Comment
Best Answer
Answer by alexpizzini · Dec 17, 2012 at 03:21 PM
transform.forward http://docs.unity3d.com/Documentation/ScriptReference/Transform-forward.html
There is also transform.right, and transform.up. http://docs.unity3d.com/Documentation/ScriptReference/Transform.html
-transform.forward is backward. -transform.right is left.
@$$anonymous$$, Thanks that is what I needed :) @clunk47, direction for game objects, exactly in vectors measuring in degrees, so it is suitable to use angleBetween = Vector3.Angle(transform.forward, targetDir);