Actor Pacing Back and Forth
tja33
Member Posts: 3
I am having trouble making my actor pace back and forth on my scene. I followed the instructions at this How-to http://gamesalad.com/wiki/how_tos:gsc_pacing
It's not working for me, and I don't know where I'm going wrong. Any suggestions would be greatly appreciated. Thanks.
It's not working for me, and I don't know where I'm going wrong. Any suggestions would be greatly appreciated. Thanks.
Comments
create an attribute in the actor called pacingDirection
add a change velocity behavior to the actor and set the direction to self.pacingDirection and speed to whatever you want...maybe 100.
Then add a timer on the actor
TIMER:
EVERY: X seconds (put in your desired X value...perhaps 1.5)
RULE: (inside the timer)
when self.pacingDirection = 0
change attribute self.pacingDirection = 180
otherwise
change attribute self.pacingDirection = 0
then add this (outside the rule but inside the timer):
change velocity with direction self.pacingDirection and speed to 100 (or whatever speed you used before).
You can substitute the change velocity with an accelerate behavior if you like to give the actor a different type of pacing effect...one that ramps up in speed and changes direction slowly as opposed to instantly like the change velocity does.
I created an attribute in my actor called 'Pace', and then created 3 rules:
Rule 1:
Every 1 second
change self.Pace to (self.Pace+1)%2 (this switches Pace from 0 to 1 every second.)
Rule2:
If self.Pace = 0
move in direction 90 at speed 100
Rule 3
if self.Pace = 1
move in direction 270 at speed 100
I suppose you could put rule 3 in an otherwise statement of rule 2. I also put some invisible boundry boxes just to make sure he didn't travel off screen. There might be better ways to do it, but it worked perfect for my needs.
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
I don't understand the first rule you outlined above. Please clarify. I change self.Pace to the following: (self.Pace+1)%2
When I enter this along with the 2 other rules, my actor just rises up the screen and then disappears.
What am I doing wrong?