LocalToWorld Help

Wondering if someone could help me with something. I have an entity with 3 child entities patented to it. I have a simple little system that moves the children around. The weird thing is when i remove the NodeMoveComponent component from the entity it jumps back to it original position. code is messy just want to get it working . please help

if (uiToolData.ActiveTool == NodeTools.MoveNode && input.GetMouseButton(0))
{
    var inputRecordData = GetSingleton<InputRecordComponent>();
    var mouseGridPos = new float3(inputRecordData.MouseGridX, 0f, inputRecordData.MouseGridZ);
 
    // Tag node
    Entities
        .WithStructuralChanges()
        .WithNone<NodeMoveComponent>()
        .WithoutBurst()
        .ForEach((Entity e, ref NodeBaseComponent s, /*in Translation t,*/ in LocalToWorld l) =>
        {
            //var cell = new float3(math.round(t.Value.x), math.round(t.Value.y), math.round(t.Value.z));
            var cell = new float3(math.round(l.Position.x), math.round(l.Position.y), math.round(l.Position.z));
            if (cell.Equals(mouseGridPos))
            {
                EntityManager.AddComponent<NodeMoveComponent>(e);
                Debug.Log($"found at {mouseGridPos}");
            }
        }).Run();

    // Node follow
    Entities
        .WithoutBurst()
        .ForEach((Entity e, ref NodeBaseComponent s, /*ref Translation t,*/ ref LocalToWorld l, in NodeMoveComponent nm) =>
        {
            Debug.Log($"Setting node too {mouseGridPos} ____________!!!!!");
            l.Value = float4x4.TRS(mouseGridPos, l.Rotation, new float3(2.0f, 2.0f, 2.0f));
            //ecb.SetComponent(e, l);
        }).Run();
}

if (uiToolData.ActiveTool == NodeTools.MoveNode && input.GetMouseButtonUp(0))
{
    Entities
        .WithStructuralChanges()
        .WithoutBurst()
        .ForEach((Entity e, ref NodeMoveComponent nm) =>
        {
            EntityManager.RemoveComponent<NodeMoveComponent>(e);
        }).Run();
}

EDIT im running UpdateAfter(typeof(TransformSystemGroup))] and if i use Translation with unparented node it also works

you are modifying local to world
as soon as you stop modifying it the transform system updates it again based off the entities translation/rotation which hasn’t changed since you started manipulating local to world.

instead you should be setting translation/rotation before the transform system and letting the transform system update the local to world.

If I recall correctly (it’s been a while since I looked at transforms) there should be a WorldToLocal component on your children which you can use to convert stuff in world space to local space.

I cant seem to find an example where a child entity was set using a world space point :frowning:

ok got it working by adding the mul of the inverse of locatToWorld and the worldPoint

That sounds right.

Ok thank you,