random movement
RocketBrain
Member, PRO Posts: 269
I cant seem to find a way to get an actor to move randomly along the x-axis.
is this possible? i tried to fake it by creating multiple actors that could bounce off of eachother offscreen but theres gotta be an easier way.
is this possible? i tried to fake it by creating multiple actors that could bounce off of eachother offscreen but theres gotta be an easier way.
Comments
and an integer attribute for the XtargetPos
Rule when self.moveRight = true
...self.XtargetPos = random(190-300)
...interpolate self.Position.X to self.XtargetPos
...Rule (embedded) >> when self.Position.X = self.XtargetPos then self.moveRight = false
Rule: when self.moveRight = false
...self.XtargetPos = random(20-130)
...interpolate self.Position.X to self.XtargetPos
...Rule (embedded) >> when self.Position.X = self.XtargetPos then self.moveRight = true
You could also make the speed of the interpolation a random number so the speed he moves will vary.
The above is the easy way...
The hard (but more elegant) way is to write a trigonometry algorithm in the expression...yes that SIN, COS and TAN stuff most of you hate.
If you care to investigate it...here is a demo...
http://gamesalad.com/game/play/47300
BTW:
a switch boolean is a TRUE/FALSE attribute....that can be used like a light switch. You can use another actor or a game controller to make it true or false (if a game attribute). When true...it turns on...when false it sits still.
In the above example...The switch is for the moving right. If true...the actor executes the right moving rule set.
When false...then the actor executes the non-true/non-right moving rule set...in this case to move left.
I recommend you do some heavy reading in the support section about some of the baseline reference stuff and demos...it will help you with the "lingo".
my creative alternate kinda worked.
[bumper] <-> [bouncer] <-> [stabilizer] <-> [bouncer] <-> [bumper]
bumpers cant move
added accelerate to each bouncer telling at certain timers to head to the middle. Stabilizer had no friction and could bounce off each bouncer.
by changing the timing and position of the bouncers it created an almost random effect on the stabilizer. make it all hidden in the background, except for the stabilizer and voila. imagine its a bit of a memory hog.
hopefully i can get your way to work synth.
Timer every 0.5 seconds
Interpolate self.motion.LinearVelocity.X to:random(-4,4)*50 duration:0.25 seconds
Here's an example I made:
http://gamesalad.com/game/play/79713
Enjoy