playMaker

Author Topic: 2d character control utilising itween?  (Read 2246 times)

harribionic

  • Playmaker Newbie
  • *
  • Posts: 10
2d character control utilising itween?
« on: March 11, 2013, 09:09:32 AM »
Hi all,

I'm moving a character left and right currently using get key and translate, which does the trick, but i'd really like to use some of that itween ease in/out niceness. Any simple workrounds? Or am I looking at the physics of the object? or even some other way?

Cheers

Stu


greg

  • Junior Playmaker
  • **
  • Posts: 68
Re: 2d character control utilising itween?
« Reply #1 on: March 14, 2013, 10:38:18 AM »
Well, i would:

- use some variables "x velocity", "z velocity" for moving the character (floats)
- clamp velocity variables to your "max speed" (like.. between -10 and 10)
- when key is down you add/subtract to each variable by "acceleration" (float variable) - higher value, faster the character will get up to max speed
- multiply velocity variables by "de-celeration", which would be a value between 0 and 0.99 every frame, lower the amount - faster the character will slow down


You can alternatively play with gravity/sensitivity in your input settings, which is far simpler but not as flexible.
« Last Edit: March 14, 2013, 10:52:58 AM by greg »