Skip to content

Commit

Permalink
added comments to CharacterAnimator
Browse files Browse the repository at this point in the history
  • Loading branch information
DerKatsche committed Feb 21, 2024
1 parent 53c506b commit 2b6a5a3
Showing 1 changed file with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ export default class CharacterAnimator implements ICharacterAnimator {
this.stateMachine.applyAction(action);
}

// -- Setup Animations --

private setupIdleAnimation(): void {
this.idleAnimation.play(true);
this.idleAnimation.setWeightForAllAnimatables(1.0);
Expand Down Expand Up @@ -94,6 +96,15 @@ export default class CharacterAnimator implements ICharacterAnimator {
);
}

@bind
private setWalkingAnimationSpeed(): void {
if (this.stateMachine.CurrentState !== CharacterAnimationStates.Walking)
return;

let velocity = this.getCharacterVelocity().length();
this.walkAnimation.speedRatio = Math.max(velocity, 0);
}

private setupInteractionAnimation(): void {
this.interactionAnimation!.onAnimationGroupEndObservable.add(() => {
this.stateMachine.applyAction(
Expand All @@ -116,6 +127,7 @@ export default class CharacterAnimator implements ICharacterAnimator {
onTransitionCallback: this.transitionFromInteractToIdle,
});
}
// -- Rotation Callback --

@bind
private rotateCharacter(): void {
Expand All @@ -139,6 +151,7 @@ export default class CharacterAnimator implements ICharacterAnimator {
this.rotationObserverRef
);
}
// -- Animation Transition --

@bind
private onBeforeAnimationTransitionObserver(
Expand Down Expand Up @@ -256,13 +269,4 @@ export default class CharacterAnimator implements ICharacterAnimator {
): number {
return this.scenePresenter.Scene.deltaTime / transitionTimeInMs;
}

@bind
private setWalkingAnimationSpeed(): void {
if (this.stateMachine.CurrentState !== CharacterAnimationStates.Walking)
return;

let velocity = this.getCharacterVelocity().length();
this.walkAnimation.speedRatio = Math.max(velocity, 0);
}
}

0 comments on commit 2b6a5a3

Please sign in to comment.