#Children stop moving with parents when I add PostTransformMatrix

1 messages · Page 1 of 1 (latest)

lost saddle
#

Hi ! I have a parent entity with several children. Some of these children need to have a non-uniform scale so I added a component PostTransformMatrix after adding the Parent component to them. The problem is that if I add this PostTransformMatrix component, the children's position is no longer updating as I move the parent (however the scale and rotation are).
I can send you more info if needed (git repository, screen captures...). I would be very grateful if someone knew how to solve this issue.

warped heron
#

is it valid?

#

potentially you may be overwriting position with invalid matrix, but I'm not sure enough if that's possible

lost saddle
#

The values are valid since the entities are displayed (values are between 0 and 0.4). They are just placed in world space rather than local space.
Until I find a solution I calculate the world position of children based on the parent position and update it every frame... Not ideal but it works

lost saddle
warped heron
#

if you want unchanged scale use identity

lost saddle
#

oh ok. I'll check my values (it cannot hurt to double check)
Thanks for your help!

lost saddle
verbal loom
#

The last row of zeroes looks suspicious; shouldn't the last element be 1.0f?

lost saddle
lost saddle
lost saddle
#

Ok so apparently I just need to do something like
ecb.AddComponent(entity, new LocalTransform{....})
I'm just not sure yet if there is a way to automatically calculate the new coordonates

verbal loom
#

The comment there refers to the fact that when an Entity's parent changes, its existing LocalTransform value will suddenly be relative to its new parent, instead of the old one. This will likely cause the entity to "snap" to some new, possibly incorrect position. The usually-expected semantics are that the object's world-space position doesn't change when its parent changed, and unfortunately it's currently the user's responsibility to manually update the LocalTransform in this case. We've discussed adding a help function to automate this, similar to the worldPositionStays parameter in UnityEngine.Transform.SetParent()