Closed AndrewRayCode closed 5 years ago
I tried setting allowSleep: false,
on the pushy body, but the behavior is the same. Also, does setting allowSleep: false
have a significant performance impact if applied to ~10 objects in a scene?
Also, interestingly, after the wall moves the block will slowly slide down until it passes where the wall was, then it moves normally.
Hi. Did you try setting the body to kinematic? http://schteppe.github.io/p2.js/docs/classes/Body.html#property_type Static bodies are assumed to have infinite mass and never move, while kinematic have infinite mass but are assumed to move. Some stuff may get cached for your walls that really shouldn't.
If this is not the problem then maybe the dynamic box gets stuck on the edge of the moving one? Try making the moving block shape slightly smaller than a full block?
10 awake bodies with integration, collision and contact solving is more than none. So yeah, try make as many as possible sleep if you can, but only if you feel like that optimization is needed. PS. sometimes you may have to .wakeUp() bodies manually.
I'm working on trigger events in my game, as in you go over an area and it triggers another event. In the below screencap, you can see I trigger a moveable wall that's under a pushy block.
However, the pushy block does not react until the player (a dynamic body) touches it. The wall is static and the block is dynamic and I update the wall's position each frame to move it. By static I mean it has mass 0. Is there a way to achieve what I want? Right now I only know the wall's data, if possible I'd prefer not to have to store the entity's data itself to wake it up. I'm looking for a generic solution that will make the block fall correctly as the wall slides.