I'm looking for a mechanic that (Using pathfinding and Line ofSight) allows the player Unit to follow an NPC wherever he goes but from a distance.
like in this video
he follows the other Unit while shooting at him at the same time when within lineofsight. Once line of sight is lost, unit stops following.
How can I achieve this?
Develop games in your browser. Powerful, performant & highly capable.
Here is a small sample of that chase mechanic built in Construct. The enemy has line of sight and move to behaviors. Tap to move the green character. The red character will chase if it has line of sight. If the red character is within attack range (stored in a range variable on the red character) it will stop moving and start shooting. If the player moves out of range, the red player will go back to chasing. If the red character loses line of sight, it has the ability to try to get it back by moving to the last known location of the player. If it reaches the last known position and still doesn't have line of sight, it stops and waits.
Very nice thx man this is exactly what I was looking for!