[SOLVED] Guard Moves That Shouldn't Move

How do I…

Make guards move ONLY if they have collision with an object in the beginning of the game.

What is the expected result

Collision with move object = Guard moves
No collision with move object = Guard is static

What is the actual result

All guards move if any of them collides with move object

Related screenshots



Why are you adding a boolean to an array variable:

image


While in this event you check it like a normal boolean variable:

image

You could simplify the actions by just using a variable:

Guard in collision with GuardMove   |  set variable MoveX of Guard to GuardMove.MoveX
trigger once                        |

variable MoveX of Guard  =/= 0      | give guard instant force of X = Guard.MoveX

This way you can have a single GuardMove object and set its MoveX variable to whatever you want, anytime a guard collides with it their MoveX variable will change to match and then they will move along X with that number of pixel/second.

So for example you could have two GuardMove, one with MoveX = -10 and one with MoveX = 10, so the guard will go back and forth between them with speed 10.

(you don’t really need to check if MoveX isn’t 0, since a 0 force wouldn’t move the object anyway)

Thank you, that fixed it!