Replies: 1 comment
-
You should be able to override @override
void postSolve(Object other, Contact contact, ContactImpulse impulse) {
// Calculate the collision force
final normalImpulse = impulse.normalImpulses[0];
final tangentImpulse = impulse.tangentImpulses[0];
// Assuming the mass of the bodies is available
final bodyA = contact.fixtureA.body;
final bodyB = contact.fixtureB.body;
final massA = bodyA.mass;
final massB = bodyB.mass;
// Calculate the force using the impulse and mass
final forceA = normalImpulse / massA;
final forceB = normalImpulse / massB;
print('Collision force on bodyA: $forceA');
print('Collision force on bodyB: $forceB');
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
There are many small balls in a container. I want to add a vibration effect when the small balls collide. However, when a collision occurs,
beginContact
orendContact
will be called a large number of times. I want to add vibration only to the collisions with greater impact and ignore those with smaller impact. But I have tested many properties and consulted the documentation and haven't found a correct way to obtain the impact force and speed.remarks: use flame_forge2d
Beta Was this translation helpful? Give feedback.
All reactions