[Solved] Running in one direction Behavior

chaosoul

  • *
  • Posts: 260
So how do you make a behavior that makes a actor run in one direction automatically while gradually gaining in speed as I'm trying to make a similar scene like canabalt. I've fiddled around with a copy of the walk behavior a few times but I just can't seem to do it. Could someone help me do it please? Thanks for all the support!

« Last Edit: July 01, 2011, 01:26:41 pm by chaosoul »
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS

Alexin

  • *
  • Posts: 3132
In the wrapper "always...", set x-speed to some Number attribute. Then, from time to time, increase this attribute. Use a "do every __ seconds" in the wrapper "when created...", for example.
"Find the fun"
alexin@stencyl.com

herby

  • Posts: 124
In the wrapper "always...", set x-speed to some Number attribute. Then, from time to time, increase this attribute. Use a "do every __ seconds" in the wrapper "when created...", for example.

If we have physics engine, there should be some solution like pushing it with a little force in the right direction, without "do every seconds", in every always block... this will make the acceleration natural. There is a group of blocks for these things there, though I do not remember the exact names now.

Alexin

  • *
  • Posts: 3132
I told him to set the velocity explicitly because it's easier for novices to understand and use. Pushing is more prone to physical interactions, though it looks more real, yes.

Actor.accelerateX(dx:Number)
Actor.accelerateY(dy:Number)
Actor.accelerate(angle:Number, speed:Number)
"Find the fun"
alexin@stencyl.com

Greg

  • *
  • Posts: 1260
The block to search for is "push [gradually]"

chaosoul

  • *
  • Posts: 260
Is this what you guys meant? http://img339.imageshack.us/img339/7190/eawtbwaeb.png
Although you guys said put the set speed on always wrapper but then that kinda ruin the effect of the push gradually at X force because even when it gained speed it would set it back to ten speed so should I put the set at x speed on the when created wrapper before the do every X seconds?
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS

Greg

  • *
  • Posts: 1260
If you want a max speed of 10, you can put an IF condition (If x-speed > 10), set x-speed = 10

chaosoul

  • *
  • Posts: 260
So its like this? because when i set it to an actor and test it out it doesn't work..http://img405.imageshack.us/img405/7190/eawtbwaeb.png
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS

Greg

  • *
  • Posts: 1260
I'd put the "if" block in the always section. 

chaosoul

  • *
  • Posts: 260
I did what you said but it seems to only reach the max speed of whatever I # put in x slot of the push gradually at X speed
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS

Greg

  • *
  • Posts: 1260
Here's what I would do

1) Scrap the "do every 2 second" logic in when created (get rid of everything in when created)
2) Add a "push [self] gradually xdir:[1] ydir:[0], force [?]"  to the "always" wrapper.  You'll have to play around with the force to get the desired acceleration
3) Right after that, put an "if x speed > max speed, set x-speed =  max speed"

chaosoul

  • *
  • Posts: 260
Thanks for the support on this
COOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEESS