Closed alrdebugne closed 3 years ago
Hi again, found the source of my problem: matter
clears events after they're emitted, so forces aren't applied (see https://github.com/liabru/matter-js/issues/134). Instead, forces have to be applied through a separate call with beforeupdate
, such as
scene.matter.world.on('beforeupdate', myFunction, this);
Closing this issue; hope this can help future users.
@alrdebugne shoot, sorry I missed this. I took a break from things over the holidays. Glad you discovered the root of the issue and documented it here. I'll add a note to the readme to help folks who might also hit this issue.
Hi Mike,
First off, many thanks for your plugin and your series of tutorials. I'm dabbling with game development during lockdown, and my initiation was made much easier through the resources you've put out here.
I don't manage to use
applyForce
on a body after its collision has been detected by ascene.matterCollision.addOnCollideActive
event. The collision is detected, butbodyB
(the object I want to apply a force to) doesn't register the force.Here's my code:
SwingState
swordHitbox
are trackedscene.bomb
, I want to apply a force to that bombIdleState
Could you help me understand what I'm doing wrong?