Random enemy movement (4-direction only)

  • My enemy Robots walk only in four directions (up, down, left, right). Using the code in the screenshot, he randomly moves in one of these four directions every 2-5 seconds.

    Please right-click, on this image, and you can view it:

    <img src="https://www.dropbox.com/s/c201w4gvss061tb/screen.png" border="0" />

    The problem: When the game loads, all of the Robots on the screen move to the top of the screen, and then will start the random movement process. How do I solve this?

    Another issue: The Robots will continue walking until they hit a solid. How can I make it so the Robots randomly stop in various locations even if it's not a solid that stops them?

    Additional thing wanted: I would like the Robots to start following the Player when they come within a certain distance of the player.

    I have read and tested many of the other enemy movement tutorials and forum posts on this site, and all of the ones I have seen are for Platform movement, or for 8-Direction movement, or for Sine movement, or for Pathfinding movement. Is there an easy way to do this with the 4-direction movement I am using?

    Thank you for your help!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Can you link me to the .capx please?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)