feat: based BumpingBehavior on world's normal

pull/267/head
alestiago 3 years ago
parent 45cd89face
commit 3231b9a6e6

@ -16,10 +16,14 @@ class BumpingBehavior extends ContactBehavior {
super.postSolve(other, contact, impulse);
if (other is! BodyComponent) return;
final worldManifold = WorldManifold();
contact.getWorldManifold(worldManifold);
other.body.applyLinearImpulse(
contact.manifold.localPoint
..normalize()
..multiply(Vector2.all(other.body.mass * _strength)),
worldManifold.normal
..multiply(
Vector2.all(other.body.mass * _strength),
),
);
}
}

Loading…
Cancel
Save