several numbers how to find the biggest one?
I have an enemy, and I want it to move towards the player that is closest to it. I know how to do distance: magnitude( self.Position.X - game.player x , self.Position.Y - game.player y )
If i get like 5 numbers for 5 different distances how can I ask the system to figure out which number is smallest?
If i can do that then i can make the enemy go towards the player closest to it
If i get like 5 numbers for 5 different distances how can I ask the system to figure out which number is smallest?
If i can do that then i can make the enemy go towards the player closest to it
Best Answer
-
tatiang Posts: 11,949
Another way is to change 5 attributes to each of your distances, game.distance1, game.distance2, etc. Then, do change attribute game.shortestDistance to min(game.distance1,min(game.distance2,min(game.distance3,min(game.distance4,game.distance5)))). Then have a rule that says When game.shortestDistance=game.distance1 --> attack enemy1; Otherwise When game.shortestDistance=game.distance2 --> attack enemy2, etc.New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Answers