Hello,
My use case is the following:
- I do a ray cast on mouse down (wasPressedThisFrame) checking my physics entity (Physics Body, Physics Shape)
- If it’s the entity I want, I instantiate a second entity (just Plane Physics Shape) which I dynamically parent to the first entity, by adding the Parent component (Value = 1st entity) and LocalToParent Component
The problem I’m running into is that the Plane Entity is instantiated at 0,0,0 even thought the link seems to be made and it has it’s LocalToWorld updated to be the same as the parents one (when I turn gravity to -0.02 my regular entity slowly raises from the ‘floor’, the plane entity remains at 0,0,0 even though the LocalToWorld matrix is updated to be the same as for the regular entity).
What I basically want to achieve is to have my Plane Entity at the same Translation as my regular Entity (Plane is set as trigger and there’s no collision between the two as I filter it out).
As a workaround I did a Job to copy the Translation from the regular entity to the plane entity such as:
[BurstCompile]
struct PlaneFollowJob : IJobForEachWithEntity<Parent>
{
[NativeDisableParallelForRestriction] public ComponentDataFromEntity<Translation> TranslationData;
public void Execute(Entity entity, int index, [ReadOnly] ref Parent parent)
{
TranslationData[entity] = TranslationData[parent.Value];
}
}
This works, however it fells like a hack and I was expecting the already existing Translation System to move the Plane with the regular entity.
Is there a better way to create this link or should I settle for my method?