Animation handler help

I’m working on animation handler for my game. Right now I just want to switch between idle and running.

Here is my code

If anyone can help I’m all ears.

William Boersma

@Leonidas you have helped me a whole lot in the past

Hi @WilliamBoersma31! How about adding an else statement after your current if statement to start your idle animation with?

@Albertos can you give some example code?

Just something like this?

// update code called every frame
AnimatioHandeler.prototype.update = function(dt) {
    var entity ='PLAYER');
    if (entity.rigidbody.linearVelocity > 1) {'RUN.glb');
    else {'IDLE.glb');

I just ended up using the inputs

If your previous way didn’t work it has probably to do with your if statement. Try linearVelocity.x instead of just linearVelocity.

hey @Albertos do you know how to make a was pressed with control stick?

I think we are already talking about that in your other topic, please reply there.

no this is different this is for the animation handler and the control stick the other one is for buttons this is just i need a way for it to fire once when you hit up on the control stick and stop when you let go of the control stick and not break the code that makes it work with the keys.

I don’t have a control stick, so I can’t help you with that. I suggest to open a new topic for that if you don’t have a topic for that already.

ok thanks