Help with Animation progress
Closed this issue · 2 comments
bribes commented
I want to make the Walking Animation start paused at a certain progress. How can I do this?
Hacksore commented
From what I can tell in the implementation you'd have to add functionality to this or move all the parts yourself.
Lines 94 to 130 in 694085b
export class WalkingAnimation extends PlayerAnimation { | |
/** | |
* Whether to shake head when walking. | |
* | |
* @defaultValue `true` | |
*/ | |
headBobbing: boolean = true; | |
protected animate(player: PlayerObject): void { | |
// Multiply by animation's natural speed | |
const t = this.progress * 8; | |
// Leg swing | |
player.skin.leftLeg.rotation.x = Math.sin(t) * 0.5; | |
player.skin.rightLeg.rotation.x = Math.sin(t + Math.PI) * 0.5; | |
// Arm swing | |
player.skin.leftArm.rotation.x = Math.sin(t + Math.PI) * 0.5; | |
player.skin.rightArm.rotation.x = Math.sin(t) * 0.5; | |
const basicArmRotationZ = Math.PI * 0.02; | |
player.skin.leftArm.rotation.z = Math.cos(t) * 0.03 + basicArmRotationZ; | |
player.skin.rightArm.rotation.z = Math.cos(t + Math.PI) * 0.03 - basicArmRotationZ; | |
if (this.headBobbing) { | |
// Head shaking with different frequency & amplitude | |
player.skin.head.rotation.y = Math.sin(t / 4) * 0.2; | |
player.skin.head.rotation.x = Math.sin(t / 5) * 0.1; | |
} else { | |
player.skin.head.rotation.y = 0; | |
player.skin.head.rotation.x = 0; | |
} | |
// Always add an angle for cape around the x axis | |
const basicCapeRotationX = Math.PI * 0.06; | |
player.cape.rotation.x = Math.sin(t / 1.5) * 0.06 + basicCapeRotationX; | |
} | |
} |
bribes commented
Alright