Actor picks random directions to move
OrbInteractive
Member Posts: 14
So I have an actor that I want to randomly path around. I'd like it to pick one of 4 directions (0, 90, 180, 270) to move, move for a random amount of time (say 1-3 seconds), then stop for a random amount of time, and finally picking a new direction continuing the cycle.
I've started by creating new integers for the actor, e.q. MoveUp = 90. How can I randomly pick one of these 4 integers as the direction and have the actor move? Or is there a way to set these numbers without making the actor integers?
If I can get the movement right I'll see about changing the image per direction.
I've started by creating new integers for the actor, e.q. MoveUp = 90. How can I randomly pick one of these 4 integers as the direction and have the actor move? Or is there a way to set these numbers without making the actor integers?
If I can get the movement right I'll see about changing the image per direction.
Comments
change attribute move to random(1,4)
if move = 1 then change your actors direction to 0
if move = 2 then change your actors direction to 90
if move = 3 then change your actors direction to 180
if move = 4 then change your actors direction to 270
That should do it.
http://jamie-cross.net/posts/ ✮ Udemy: Introduction to Mobile Games Development ✮ Learn Mobile Game Development in One Day Using Gamesalad ✮ My Patreon Page
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
Timer Every: 3 seconds
-- Timer After: random(1,3) seconds (√ Run to Completion)
---- Change Velocity
------ Direction: random(0,3)*90 Relative to: scene
------ Speed: (your choice)
---- Timer After: random(1,3) seconds (√ Run to Completion)
------ Change Velocity
-------- Direction: 0 Relative to: scene
-------- Speed: 0
Guru Video Channel | Lost Oasis Games | FRYING BACON STUDIOS