It was removed in pre.65, so, How do i replace it? please give me a complete complete code, thanks
1 Like
Use TransformComponent
I wrote that but nothing happened
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Entities;
using Unity.Transforms;
public partial class MovingSystemBase : SystemBase
{
protected override void OnUpdate()
{
foreach (LocalTransform trans in SystemAPI.Query<LocalTransform>())
{
trans.Translate(new Unity.Mathematics.float3(1, 0,0));
}
}
}
Of course, because Translate returns new value which you should assign to LocalTransform back, have you checked method signature, and return value havent disturbed you? It’s even explicitly mentioned in method remarks.
I searched for a day and still can’t find a way to move objects. god
I am not at my computer, but maybe this will already be enough to make it work.
trans = trans.Translate(new Unity.Mathematics.float3(1, 0,0));
You need to use RefRW otherwise you’re just getting a read only copy of LocalTransform
foreach(var transRW in SystemAPI.Query<RefRW<LocalTransform>>())
{
ref var trans = ref transRW.ValueRW;
trans = trans.Translate(new float3(1, 0,0));
// Or
// trans.Position = trans.Position + new float3(1, 0, 0);
}
2 Likes