I'm trying to tell if the player is within a 120 degree viewcone in front of an enemy. I'm having an issue figuring out the angle between the two relative to the enemy's rotation.
So I get the angle between the player and the enemy:
var angle = rad2deg(Vector2(pos.x, pos.z).angle_to(Vector2(ppos.x - pos.x, ppos.z - pos.z)));
And then I get the rotation of the enemy:
var myrot = rad2deg(transform.basis.get_euler().y);
So how do I get the angle relative to the enemy's rotation? I had assumed it'd just be adding them together, but that makes it difficult to make sure that the angle is within the 120 degree viewcone, as the added angles will often be higher than the angle should even be able to go.