So, I'm attempting to make an engine where enemies are able to detect the proximity of a player without the need for a secondary object. The items I have in frame are "Player" (and Eight Directions Object), and "Enemy" (A bouncing Ball Object)
Enemy has the following attributes:
A- XPos (Enemies X Position) - 0
B- YPos (Enemies Y Position) - 0
C- XDet (Players X Position) - 0
D- YDet (Players Y Position) - 0
E- Sight (Range of sight) - 80
The code I have is:
>Always: Set XPos(Enemy) to Abs(X("Enemy))
>Always: Set YPos(Enemy) to Abs(Y("Enemy))
>Always: Set XDet(Enemy) to Abs(X("Player))
>Always: Set YDet(Enemy) to Abs(Y("Player))
>When Enemy's (Abs(XPos("Enemy")-XDet("Enemy")) <= Sight("Enemy")
>When Enemy's (Abs(YPos("Enemy")-YDet("Enemy")) <= Sight("Enemy"): Start Enemy
The goal is to make it so when Player is within 80 pixels of Enemy, the enemy will start. I have counters that show both the XPos-XDet and YPos-YDet in-game, showing that the equation isn't the problem, but it still won't respond to the "Start" command unless I do some arbitrary random movement. Please help.