ssatguru / BabylonJS-CharacterController

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

testAnimationGroup from GLB not working #47

Closed bigrig2212 closed 1 year ago

bigrig2212 commented 2 years ago

Hi - just downloaded, npm installed and clicked "test animation group (using a .glb file)" Character moves around, but does not change animation state (frozen state). Haven't dived into it yet... but that's what i get on first install. Works fine in .babylon format.

bigrig2212 commented 2 years ago

Is there supposed to be something that gets set here to make the GLBs work in CharacterController?

Screen Shot 2022-02-21 at 12 53 22 PM
bigrig2212 commented 2 years ago

Or maybe that the anim.exist objects are set to false? Seems like something not working with setActionMap function.

Screen Shot 2022-02-21 at 1 21 54 PM

Or this bit... where rangeName is not of type AnimationGroup

Screen Shot 2022-02-21 at 1 56 49 PM
echan00 commented 2 years ago

@bigrig2212 have you had any luck? also have the same question.

EDIT: can confirm GLB animations are not implemented (or correctly)

echan00 commented 2 years ago

Try remove this._hasAnims from the function below: It worked for me!

        //removed to get GLB to work, if (!this._stopAnim && anim != null && this._hasAnims) 
        if (!this._stopAnim && anim != null) {
            if (this._prevAnim !== anim) {
                if (anim.exist) {
                    if (this._isAG) {
                        if (this._prevAnim != null && this._prevAnim.exist) this._prevAnim.ag.stop();
                        //TODO use start instead of play ?
                        //anim._ag.play(anim._loop);
                        //anim._ag.speedRatio = anim._rate;
                        anim.ag.start(anim.loop, anim.rate);
                    } else {
                        this._skeleton.beginAnimation(anim.name, anim.loop, anim.rate);
                    }
                }
                this._prevAnim = anim;
            }
        }
ssatguru commented 2 years ago

@bigrig2212 Sorry was away and missed this. You are right , I must have broken something. @echan00 Thanks for looking into this and the fix

Hopefully I can get to this by end of this week.

ssatguru commented 2 years ago

@bigrig2212 @echan00 This should be fixed. The previous version (0.4.3) constructor took AnimationGroup as a parameter The new alpha version constructor can take a ActionMap/AnimationGroup as parameter A bug broke backward compatibility. Have now fixed that bug.

Next time I will build alpha versions in their own branch so as to not break existing test/demos.

Please test and close if it works for you.

bigrig2212 commented 1 year ago

Yay, your fix works great. This sample was key to getting it working: https://github.com/ssatguru/BabylonJS-CharacterController/blob/master/tst/testAnimationGroup.js