Press two keys at the same time | Animation after every other animation is stopped

Hey guys³

run animation while W and SHIFT pressed at the same time

I want to call the runRange animation of the character, when W and SHIFT are being pressed at the same time.
I already tried
In line 101 I already tried
if (inputMap["w"] && inputMap["Shift"]) {
scene.beginAnimation(skeleton, runRange.from, runRange.to, true);
}
and
if (inputMap["Shift"])
in the if (inputMap["w"]) statement, but nothing seems to work to get the run-animation animated.

idle animation when no key is pressed

Also I want to run the idle animation, when no key is pressed.
I thought it would be a good idea if I call the animation in line 116 after every other animation is stopped. But you can guess it - it didn’t work and I’m out of ideas.

Example:
https://www.babylonjs-playground.com/#BCU1XR#323

Like in my two other threads today I hope you can give me some ideas.
Thank you in advance!

you can debug the input map by just printing it out, in this case when you hold down shift it would cause W to be down instead of w, to workaround this you can make it set to lowercase always

For the idle issue, animations must only be started once per frame so they can play their full animation, an idle flag can be added to avoid this.

https://www.babylonjs-playground.com/#BCU1XR#327

1 Like

Nice, this is an easy solution. Thank you again :slight_smile:

What I don’t get is, in my playground the character moves faster with ‘Shift’ with a capital s and it doesn’t seem to work with ‘shift’. But in your playground it is vise versa.

Edit: I only missed that you changed the input map in line 44 and 47.

I just changed the one S to s in line 83 and the character can move faster now

https://www.babylonjs-playground.com/#BCU1XR#330