Quantcast
Channel: Latest Questions on Unity Answers
Viewing all articles
Browse latest Browse all 171066

How to get an object's direction relative to the camera?

$
0
0
I only know how to do it when the camera's Y rotation is set to 0. This's what I did: void GetDirection () { float headingAngle = transform.rotation.eulerAngles.y; if (headingAngle > 315 || headingAngle < 45) anim.SetBool("GoForward",true); else if (headingAngle < 225) anim.SetBool("GoLeft",true); else if (headingAngle < 135) anim.SetBool("GoBackward",true); else anim.SetBool("GoRight",true); } However this won't work when camera rotates, since the "forward angle" is not 0. I seriously don't know how to the angle calculation when the angle goes over 360.

Viewing all articles
Browse latest Browse all 171066

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>