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

Get help using Construct 2

Post » Fri Mar 13, 2015 5:20 pm

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!
B
4
S
1
Posts: 12
Reputation: 507

Post » Fri Mar 13, 2015 5:38 pm

@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.
B
10
S
1
Posts: 93
Reputation: 722

Post » Fri Mar 13, 2015 5:51 pm

Oh thanks I'll give that a try! Thanks for your help :)
B
4
S
1
Posts: 12
Reputation: 507


Return to How do I....?

Who is online

Users browsing this forum: blissfulwizard, DevinMurray, newt and 18 guests