Skip to content

Commit

Permalink
fix: restitution was acting like friction when 0 < restitution < fric…
Browse files Browse the repository at this point in the history
…tion (#440)
  • Loading branch information
dragoncoder047 authored Oct 8, 2024
1 parent 3f5436d commit 83ff414
Showing 1 changed file with 2 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/components/physics/body.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,8 @@ export function body(opt: BodyCompOpt = {}): BodyComp {

// Clear the velocity in the direction of the normal, as we've hit something
if (this.vel.dot(col.normal) < 0) {
if (restitution == 0) {
this.vel = rejection;
}
else {
// Modulate the velocity tangential to the normal
this.vel = this.vel.reflect(col.normal).scale(
restitution,
);
}
// Modulate the velocity tangential to the normal
this.vel = rejection.sub(projection.scale(restitution));
}

if (friction != 0) {
Expand Down

0 comments on commit 83ff414

Please sign in to comment.