Check if rotation if facing towards a vector3
I have 2 moving objects. A player and an enemy. I want to know when my enemy is facing towards my player. Note that I don't want to know exactly when, but rather when its close to facing the right way. I tried with:
float angle = 25;
if (Vector3.Angle(transform.forward, player.transform.position - transform.position) < angle)
{
}
I tried to debug the angel you get in the "if" statement and when the player stand still, the value is constant when the enemy goes back and forth. Hope you can help! (note: this scripts is attached to the enemy!) Link to how is looks. Look at the console for the debug.log of the if statement thingy! https://gyazo.com/4529c07f2aecf5195f060d1165ee57e7
Comment