How to move enemy sprite up down left and right randomly?

0 favourites
  • 3 posts
From the Asset Store
A complete set of graphical user interface (GUI) to build 2D video games. With wood, nature, & jungle theme
  • Hey guys, basically I want my "enemy AI" to move randomly up down left and right, for example "Every X seconds change direction to up/down/left/right" I can get it to move at random diagonals and move randomly in general but I only want it to move in those 4 directions.

    I'm sure its something simple and I'll be like D'oh! Thanks in advance!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Pbodeh This is how i have managed to do this in one of my games

    Add bullet behavior to the sprite you want to move in those 4 directions(set Bounce off solids Enable)

    In event sheet try something like

    Condition:

    Every random(4,10) seconds

    Action>Sprite

    Set Bullet angle of motion 90 degrees

    Condition:

    Every random(4,10) seconds

    Action>Sprite

    Set Bullet angle of motion 180 degrees

    Condition:

    Every random(4,10) seconds

    Action>Sprite

    Set Bullet angle of motion 0 degrees

    Condition:

    Every random(4,10) seconds

    Action>Sprite

    Set Bullet angle of motion -90 degrees

    Play around with it a little and hopefully you'll get the result you're looking for.

  • Oh thanks I'll give that a try! Thanks for your help

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