Move enemy back and forth while player is not in vision

Hi, I’m making a platformer game and the enemy should move back and forth while the player is not touching the vision of the enemy(the purple box). However the enemy get stuck when it’s touching the right border. How do I fix this. please help. Thanks



Here’s my code:

Anyone ??? Pls help.

Please anyone? ……………

This:

clashes with this:

Use an object variable on the GoundMobs obejcts that tracks the direction the force should be applied. Set this variable when the GroundMobs object collides with a Left or Right block, and only have the one apply force in the first event (i.e. get rid of the forces when the GroundMobs collides with a Left or Right block).


BTW, this pick all instances will cause you problems:

image

1 Like

Hi thanks so much I’ll fix it