version 4.0.1 dynamic bodies don't inherit position from parent
Interactimation opened this issue ยท 2 comments
In version 4.0.1 of the A-Frame Physics Engine, static bodies DO but dynamic bodies DO NO inherit position information from parent entities
EXAMPLE: https://glitch.com/~aps-401-parent-bug
the boxes and spheres are all children of a "control entity" with a
position="0 0 -25"
static-body boxes therefore have a position z=0
BUT
dynamic-body spheres have to have their position z=-25
to match
I know that this was not an issue a year ago, today - what happened?
@Interactimation thanks so much for raising this issue. I've not been able to reproduce the behaviour you described where dynamic bodies did inherit position information from parent entities. I have tried this with v3.0.0
https://unpkg.com/aframe-physics-system@3.0.0/dist/aframe-physics-system.min.js
which was published over a year ago and it still has the same behaviour where dynamic bodies no not inherit position information. If you can, could I please ask you to provide an example of the previous behaviour you said existed a year ago, thanks ๐
In general though I agree that irrespective of the previous behaviour, this does look like a bug. Static bodies and dynamic bodies should inherit consistently. I'm looking into this now and will update this issue shortly, thanks again for raising this ๐
I have a candidate solution for this issue. If we take a look at how physics bodies are initialised
aframe-physics-system/src/components/body/body.js
Lines 41 to 53 in 59c346a
we see that they simply take on the local position and rotation. It seems for static bodies the particular path through the code in src/components/body/body.js
ends up correcting this issue, so you end up with the static body in the correct place inheriting from the parent. However for dynamic bodies, the path is slightly different and it ends up maintaining this initialised position which does not inherit from the parent.
I have a simple candidate fix using updateWorldMatrix
that resolves this issue for me locally and is similar to how the position and rotation of the body is normally (and correctly) synced to the physics engine
aframe-physics-system/src/components/body/body.js
Lines 300 to 303 in 59c346a
I need to write up a test or two for this to prevent future regressions, but this should be on master in the next 1-2 days and a published version shortly after that ๐ I'll update with progress as it comes.