Skip to content

Commit

Permalink
feat: Always clear velocity (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
mflerackers authored Oct 2, 2024
1 parent 88187f3 commit 37c8d67
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/components/physics/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,6 @@ export function body(opt: BodyCompOpt = {}): BodyComp {
this.onPhysicsResolve((col) => {
if (game.gravity) {
if (col.isBottom() && this.isFalling()) {
// Clear the velocity in the direction of the normal, as we've hit something
this.vel = this.vel.reject(
col.normal,
);
// We need the past platform to check if we already were on a platform
const pastPlatform = curPlatform;
curPlatform = col.target as GameObj<
Expand All @@ -286,13 +282,15 @@ export function body(opt: BodyCompOpt = {}): BodyComp {
}
}
else if (col.isTop() && this.isJumping()) {
this.vel = this.vel.reject(
col.normal,
);
this.trigger("headbutt", col.target);
col.target.trigger("headbutted", this);
}
}

// Clear the velocity in the direction of the normal, as we've hit something
this.vel = this.vel.reject(
col.normal,
);
});
}
},
Expand Down

0 comments on commit 37c8d67

Please sign in to comment.