I’ve posted twice about this issue and yet to receive any response. I might have to make a super simple bug repro project and submit a bug report, but it’s not had to reproduce.
Ok, that would be great. It is indeed a nasty bug, my project basically came to a halt because of this. I have to establish parent child relationships in my game all the time.
I hope they can fix this soon or explain, what we are doing wrong here…
When an entity has no parent translation and rotation components they are effectively in world space.
However when an entity has a parent they are in local space.
I’m trying to use just LocalToWorld, and adding Parent and LocalToParent components resets LTW to 0,0,0.
I believe the correct response would be LTW keeps its current value and LTP is set to the difference between the Parent entities LTW and the child entities LTW.
However, LTW and LTP are both zeroed out, which makes absolutely no sense. How could the child have a LTP of 0,0,0 and a LTW of 0,0,0 when the parent is not at 0,0,0 itself?
In conversion the local rotation / translation are set for you if you have a parent.
if (hasParent)
{
DstEntityManager.AddComponentData(entity, new Translation { Value = transform.localPosition });
DstEntityManager.AddComponentData(entity, new Rotation { Value = transform.localRotation });
if (transform.localScale != Vector3.one)
DstEntityManager.AddComponentData(entity, new NonUniformScale { Value = transform.localScale });
DstEntityManager.AddComponentData(entity, new Parent { Value = GetPrimaryEntity(transform.parent) });
DstEntityManager.AddComponentData(entity, new LocalToParent());
}
else
{
DstEntityManager.AddComponentData(entity, new Translation { Value = transform.position });
DstEntityManager.AddComponentData(entity, new Rotation { Value = transform.rotation });
if (transform.lossyScale != Vector3.one)
DstEntityManager.AddComponentData(entity, new NonUniformScale { Value = transform.lossyScale });
}
I haven’t really played with this but you will probably to need to replicate this behavior yourself. Not saying this is ideal, just how it is at the moment.