#Problem with animation, animation enter in a Loop with key "J"
4 messages · Page 1 of 1 (latest)
class IdleState extends State {
constructor(parent) {
super(parent);
}
get Name() {
return 'idle';
}
Enter(prevState) {
const idleAction = this._parent._proxy._animations['idle'].action;
if (prevState) {
const prevAction = this._parent._proxy._animations[prevState.Name].action;
idleAction.time = 0.0;
idleAction.enabled = true;
idleAction.setEffectiveTimeScale(1.0);
idleAction.setEffectiveWeight(1.0);
idleAction.crossFadeFrom(prevAction, 0.5, true);
idleAction.play();
} else {
idleAction.play();
}
}
Exit() {
}
Update(_, input) {
if (input._keys.forward || input._keys.backward) {
this._parent.SetState('walk');
}
else if (input._keys.space) {
this._parent.SetState('success');
}
else if(input._keys.sad_j) {
this._parent.SetState('failure');
}
}
};```
class FailureState extends State {
constructor(parent) {
super(parent);
this._FinishedCallback = () => {
this._Finished();
}
}
get Name() {
return 'failure';
}
Enter(prevState) {
const curAction = this._parent._proxy._animations['failure'].action;
const mixer = curAction.getMixer();
mixer.addEventListener('finished', this._FinishedCallback);
if (prevState) {
const prevAction = this._parent._proxy._animations[prevState.Name].action;
curAction.reset();
curAction.setLoop(THREE.LoopOnce, 1);
curAction.clampWhenFinished = true;
curAction.crossFadeFrom(prevAction, 0.2, true);
curAction.play();
} else {
curAction.play();
}
}
_Finished() {
this._Cleanup();
this._parent.SetState('idle');
}
_Cleanup() {
const action = this._parent._proxy._animations['failure'].action;
action.getMixer().removeEventListener('finished', this._CleanupCallback);
}
Exit() {
this._Cleanup();
}
Update(_) {
}
};```
i follow this tutorial but now i have 2 dance states one sucess another failure