aframe-physics-system
aframe-physics-system copied to clipboard
Removing and re-adding static-body does not work as expected
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 astatic-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 thephysics="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 thekinematic-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 firesel.setAttribute(
static-body', '')you should see the red debug wireframe drawn back around the door model, but the collision will not affect the
kinematic-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
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.
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.