Skip to content

Commit afc1e5c

Browse files
authored
Crouch animation improvement (#204)
1 parent c7ab8f9 commit afc1e5c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

src/animation.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,16 +316,18 @@ export class CrouchAnimation extends PlayerAnimation {
316316
player.elytra.position.z = player.cape.position.z;
317317
player.elytra.rotation.x = player.cape.rotation.x - (10.8 * Math.PI) / 180;
318318
const pr1 = this.progress / this.speed;
319-
if (Math.abs(Math.sin((pr * Math.PI) / 2)) === 1) {
319+
if (Math.abs(Math.sin((pr * Math.PI) / 2)) === 1 || (this.showProgress && Math.floor(Math.abs(pr)) % 2 === 0)) {
320320
this.erp = !this.isCrouched ? pr1 : this.erp;
321321
this.isCrouched = true;
322322
player.elytra.leftWing.rotation.z =
323323
0.26179944 + 0.4582006 * Math.abs(Math.sin((Math.min(pr1 - this.erp, 1) * Math.PI) / 2));
324+
player.elytra.leftWing.rotation.y = 0.3 * Math.abs(Math.sin((Math.min(pr1 - this.erp, 1) * Math.PI) / 2));
324325
player.elytra.updateRightWing();
325326
} else if (this.isCrouched !== undefined) {
326327
this.erp = this.isCrouched ? pr1 : this.erp;
327328
player.elytra.leftWing.rotation.z =
328329
0.72 - 0.4582006 * Math.abs(Math.sin((Math.min(pr1 - this.erp, 1) * Math.PI) / 2));
330+
player.elytra.leftWing.rotation.y = 0.3 - 0.3 * Math.abs(Math.sin((Math.min(pr1 - this.erp, 1) * Math.PI) / 2));
329331
player.elytra.updateRightWing();
330332
this.isCrouched = false;
331333
}

0 commit comments

Comments
 (0)