Hello, I was trying to make a simple npc thing that the server will own. And I simply added a translate test system:
[GhostComponent()]
public struct TranslationSpeed : IComponentData
{
public float3 speed;
}
[BurstCompile]
partial struct TestSystem : ISystem
{
public void OnUpdate(ref SystemState state)
{
float deltaTime = SystemAPI.Time.DeltaTime;
foreach (var (transform, speed) in SystemAPI.Query<RefRW<LocalTransform>, RefRO<TranslationSpeed>>())
transform.ValueRW = transform.ValueRO.Translate(speed.ValueRO.speed * deltaTime);
}
}
[DisallowMultipleComponent]
public class TestAuthoring : MonoBehaviour
{
public class Baker : Baker<TestAuthoring>
{
public override void Bake(TestAuthoring authoring)
{
Entity entity = GetEntity(TransformUsageFlags.Dynamic);
AddComponent(entity, new TranslationSpeed() { speed = new float3(0,0.3f,0) });
}
}
}
But when I build and run (is it possible to have several view of clients in the editor btw ?), the npc start moving from the start position for each connected player.
I tried to filter the system for only the system, and then I saw in the editor than the server localToWorld was moving but not the client one.
So does it means that localTransform is not synchronized for ghost entities ? Even if they are dynamic ?
Do I need to add some kind of Translate GhostComponent and then compute the localToWorld on each side ? Is it the "good" practice ?
Thanks for your time !