|
Im using the following script to apply damage to my enemies This works well, but i don't want to attack the enemy if it is behind me. how cab i get the rotation of the object so i can use it in an if statement, or is there another way to do it? Please Help
(comments are locked)
|
|
If your player has a camera you could try this: http://unity3d.com/support/documentation/ScriptReference/Camera.WorldToViewportPoint.html and make sure his viewpoint coords are between 0 and 1 (or whatever field of view you like). If not, you could create a vector from player to enemy, and cross-product that with the player's forward vector. If the resulting Y component points up, he's in front, if down, he's behind (or something like that)
(comments are locked)
|

You could use SphereCast.