What can I use to replace TransformAspect?

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? :slight_smile: It’s even explicitly mentioned in method remarks.
8932815--1224642--upload_2023-4-7_10-10-3.png

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