Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: harribionic on March 11, 2013, 09:09:32 AM

Title: 2d character control utilising itween?
Post by: harribionic 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

Title: Re: 2d character control utilising itween?
Post by: greg 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.