Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -594,23 +594,26 @@ export default class DefaultPlayerEntityController extends BaseEntityController
}

// Handle movement animations and audio
const scaleMultiplier = entity.height / DefaultPlayerEntityController.BASE_ENTITY_HEIGHT;
if (this.isGrounded && !this.isSwimming && this._isActivelyMoving && !hasConflictingInputs && canMove) {
// Ground movement animations
const animations = isFastMovement ? this.runLoopedAnimations : this.walkLoopedAnimations;
entity.stopAllModelAnimations(animation => animations.includes(animation.name) || animation.loopMode === EntityModelAnimationLoopMode.ONCE);
for (const animation of animations) {
entity.getModelAnimation(animation)?.setLoopMode(EntityModelAnimationLoopMode.LOOP);
entity.getModelAnimation(animation)?.play();
entity.getModelAnimation(animation)?.setPlaybackRate(scaleMultiplier);
}
this._stepAudio?.setPlaybackRate(isFastMovement ? 0.75 : 0.51);
this._stepAudio?.setPlaybackRate((isFastMovement ? 0.75 : 0.51) * scaleMultiplier);
this._stepAudio?.play(entity.world, !this._stepAudio?.isPlaying);
} else if (this._isFullySubmerged && this.canSwim(this)) {
this._stepAudio?.pause();
if (this._isActivelyMoving) {
entity.stopAllModelAnimations(animation => this.swimLoopedAnimations.includes(animation.name) || animation.loopMode === EntityModelAnimationLoopMode.ONCE);
for (const animation of this.swimLoopedAnimations) {
for (const animation of this.swimLoopedAnimations) {
entity.getModelAnimation(animation)?.setLoopMode(EntityModelAnimationLoopMode.LOOP);
entity.getModelAnimation(animation)?.play();
entity.getModelAnimation(animation)?.setPlaybackRate(scaleMultiplier);
}
} else {
entity.stopAllModelAnimations(animation => this.swimIdleLoopedAnimations.includes(animation.name) || animation.loopMode === EntityModelAnimationLoopMode.ONCE);
Expand Down