How to auto animate character movement - unreal engine 4?

Need help with character movement engine in flash cs4 with as2.0 thanks :)?

  • Whats wrong? onClipEvent(load){ rightspeed = 0; leftspeed = 0; jump = 0; } onClipEvent(enterFrame){ if(Key.isDown(Key.RIGHT)){ rightspeed = rightspeed + 10; } rightspeed = rightspeed - 2.5; this._x = rightspeed; } onClipEvent(enterFrame){ if(Key.isDown(Key.LEFT)){ leftspeed = leftspeed + 10; } leftspeed = leftspeed - 2.5; this._x -= leftspeed; } }else if(Key.isDown(Key.UP)){ this._y -= 3.5; }

  • Answer:

    What does it do? The only thing I would add is this._x = ((rightspeed - 2.5)>0)?rightspeed - 2.5:0; and this._x = ((leftspeed - 2.5)>0)?leftspeed - 2.5:0; This is a short circuit evaluation if/else: if the math is > 0, apply it, otherwise set it to zero. Otherwise it will begin applying negative numbers to the position, taking it off the state - maybe that's what's wrong. Use trace('message') to debug, see documentation. trace('rightspeed is ' + rightspeed);

Lennon C at Yahoo! Answers Visit the source

Was this solution helpful to you?

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.