I have this code:
Conditions:
For each object playermeleeunit:
Variable moving of playermeleeunit = 0
Variable incombat of playermeleeunit = 0
The distance between playermeleeunit and enemymeleeunit < 300 pixels
Variable incombat of enemymeleeunit = 0
Actions:
Unlink all objects from playermeleeunit
Stop object playermeleeunit
Stop object enemymeleeunit
Link playermeleeunit and enemymeleeunit
Do = 1 to variable incombat of playermeleeunit
Do = 1 to variable incombat of enemymeleeunit
Do = playermeleeunit.Variable(ID) to variable target of enemymeleeunit
Do = enemymeleeunit.Variable(ID) to variable target of playermeleeunit
Move playermeleeunit to enemymeleeunit with a force of playermeleeunit.Variable(movespeed)*
*Other stuff happens when the playermeleeunit reaches the enemymeleeunit.
The problem is, if a playermeleeunit spawns and there are multiple enemies in range, then ALL enemies change their combat status and targets as though they are battling the playerunit. I don’t know why this is happening? :S