ssatguru / BabylonJS-CharacterController

A CharacterController for BabylonJS
Apache License 2.0
216 stars 46 forks source link

Add animations with new keyboard controls #7

Closed dad72 closed 4 years ago

dad72 commented 4 years ago

Hi, I tried your CharacterController which works rather well, but we can only add predefined animation (like walking, running, jumping ...) Can we add other animations like: punch, kick, sit, push, pick up, pull. We are quite limited now, we can not do a fighting game for example.

It would be great to have other possibilities of animation and possibilities to add other keyboard commands.

This is the only limit I currently find

Thanks

ssatguru commented 4 years ago

Hi @dad72 You can change any of the animations any time.

if (talking) cc.setWalkAnim("myWalkTalkAnim",0.5,true);
else if (fighting) cc.setWalkAnim("myWalkFight",0.5,true);
else cc.setWalkAnim("myWalkPlain",0.5,true);

You can also pause charactercontroller animations, play any of you animation and then resume charactercontroller

cc.pauseAnim();
//play your animations
....
cc.resumeAnim();

https://github.com/ssatguru/BabylonJS-CharacterController/blob/master/src/CharacterController.ts#L379

Thanks

dad72 commented 4 years ago

Ok I see. The second solution with pauseAnim and resumAnim seems to me well.

bigrig2212 commented 1 year ago

Hi all. Problem i have is that pauseAnim() seems to lock the GLB into idle animation state instead of pausing. So, the secondary animation plays and then it resumes to the idle state. It does the same thing on Vincent, so i dont think it's my GLB.

The only time it works is if i pause directly after doing cc.start(). Anytime later and it doesn't work.

I wonder, since pauseAnim only sets a property - does it need to do something more?