#GameObject.Transform vs Entities.Transform - Need help

1 messages · Page 1 of 1 (latest)

ember niche
#

Hello!
I'm in the process to move from a gameobject project to a ECS one.
I made a small static class to help convert gameobject.transform modification to work with Entities.transform to the other based on the documentation in the manual : https://docs.unity3d.com/Packages/com.unity.entities@1.0/manual/transforms-comparison.html Doing ( supposedly ) the same thing.

The final code i'm migrating is :

SphereCollisionPoserAuthoring authoring = mainTarget.GetComponent<SphereCollisionPoserAuthoring>();
            
            mainTarget.transform.GetLocalPositionAndRotation(out Vector3 positionL, out Quaternion rotationL);
            mainTarget.transform.SetLocalPositionAndRotation(float3.zero, rotationL);
            mainTarget.transform.GetPositionAndRotation(out Vector3 position, out Quaternion rotation);
            
            float3 positionP = position;
            float magnitude = math.length(position);
            float num2 = authoring.clampRadius;
            float num3 = magnitude + num2;
            float num4 = (num3 + math.sqrt(math.max(0f, num3 * num3 - 4f * (magnitude * num2 - num)))) / 2f;
            positionP = math.normalizesafe(positionP) * num4;
            mainTarget.transform.SetPositionAndRotation(positionP, rotation);

And mainTarget have a parent that move too.
Do anyone see an error that would explain some discrepencies in the final results ?