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); super.postSolve(other, contact, impulse);
if (other is! BodyComponent) return; if (other is! BodyComponent) return;
final worldManifold = WorldManifold();
contact.getWorldManifold(worldManifold);
other.body.applyLinearImpulse( other.body.applyLinearImpulse(
contact.manifold.localPoint worldManifold.normal
..normalize() ..multiply(
..multiply(Vector2.all(other.body.mass * _strength)), Vector2.all(other.body.mass * _strength),
),
); );
} }
} }

Loading…
Cancel
Save