aframe-physics-system icon indicating copy to clipboard operation
aframe-physics-system copied to clipboard

Removing and re-adding static-body does not work as expected

Open donmccurdy opened this issue 7 years ago • 2 comments

From user on Slack:

I do already have collision setup in my scene. My camera entity has kinematic-body, which nicely collides with all the walls that are setup when the scene initializes. In this case I'm struggling with I have a static-body on an object, which is colliable, I remove it, then based on an event add it back. I used your updated line .setAttribute('static-body', '') and the physics="debug: true is showing new collision rendered around the object, yet my camera still walks through it. Do I need to refresh a list so that the kinematic-body on the camera, plus any other dynamic colliders will now observe it?

Here's a link to a scene that has the collision issue: http://34.197.38.143/seedfinder/wolf3d.html To repro it, use WASD to approach the door and click the mouse to activate the open animation. The action first removes the static-body then the door automatically closes after about 3 seconds and at the end of the animation fires el.setAttribute(static-body', '')you should see the red debug wireframe drawn back around the door model, but the collision will not affect thekinematic-bodyattached to the camera letting it move through freely. All the code is in the.html` Line 195 removes the collision body Line 210 re-adds the collision body

donmccurdy avatar Sep 15 '17 18:09 donmccurdy

Hold off looking at this. I think I may have found a bug elsewhere in my code. I've just created another project and changed my code and the physics bug has gone.

There still may be some issue though because in the original instance the debug render is drawing around the broken physics setup. I'll see if I can get an exact point on the break.

roskelld avatar Sep 18 '17 00:09 roskelld

So, removing and re-adding static-body seems fine when running in the main thread, but with physics="driver: worker" something does get out of sync and throws an error. Will need to fix that I think.

donmccurdy avatar Feb 11 '18 06:02 donmccurdy