planck.js
planck.js copied to clipboard
Bug? Continuous collision detection does not work after bodies are created
edit: the real situation was different, than what i am describing here. it is not a bug with planck, see mein next post.
Hi,
i have two dynamic bodies.
The first one is my player, it is initialized like this: world.createBody({bullet: true});
The second one is created without the bullet-property.
When i apply a strong force to my player object, targeting the second body, the player just goes through it.
But when i first touch the second body slightly with my player body, and then apply the strong velocity, everything works as expected and the second body is thrown away.
i have tried to initialize the second body with
world.createBody({
allowSleep: false,
awake: true,
});
but this has not changed anything.
After both bodies have touched once, it seems that the CCD works always, but not right after initialization.
Am i doing something wrong, or is this a bug?
Thanks for reporting this, could you please share a testbed example to reproduce it?
i will try to create one tonight is there a way to set the testbed to a fixed timestep of 30ms?
ok, i have investigated it further more. the problem is different from that what i was describing in my first post and its not a bug with planck.
Basically, i have a "spawn" protection, which disables the collisions for other entities till the player-body leaves the spawn.
(the spawn is just a tiny body with static:true,isSensor:true
)
Unfortunately, in my case, the "end-contact" just resolves, after the player has crossed the other entity, so nothing happened.
How would you do this with planck? https://piqnt.com/space/7iE4dcA98 (wait 2 sec after starting for the initial impulse)
in my real project, i have an update-loop, that checks for each player in spawn, and turns on the collision, once the player has no contacts (m_contactList==null), in order to prevent, that collision is turned on, when two bodies are inside of each other. But that is also just called completely after the timestep and therefore does not work.
Ah yes, you need to call refilter()
after changing contact filtering:
bf.setFilterMaskBits(filter | 1);
bf.refilter();
Also you may want to check if the contact event belongs to your spawn, see SensorTest.
I fixed this, now it automatically calls refilter after setFilter... functions. Thanks for reporting!