I have the following game scenario:
Player is P and there are 2 enemies E1 and E2
I want to calculate the distance between the ennemies and the player base which is anywhere in that green line, and not the actual player character.
Currently if if I try to calculate the distance between enemies and players I get something like this:
But what i really want is this:
Now i could've just raycast from the enemies forward to hit the "base collider" but this is what am trying to avoid.
My question is:
If the green line is always going to be a "longer version" of the player Transform.Right vector, is there a way to project the Enemies Transform.forward vector, and now where it intersects with the player vector like this:
If you're curious about the reason behind this, then this image should clarify it:
Basically I need to create a "high threat zone" in front of the player, and based on the enemy distance to the "player base", i will give different feedback.