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