#Entity Creation Example unable to query spawned entities.

1 messages · Page 1 of 1 (latest)

ebon wraith
#

From the URPSamples im running the "EntityCreation" scene, im trying to add a System that moves the spawned Entities however im unable to query these. I've added a tag to the Entities as you can see in the picture.

Then I try to query these tags (and move or do smth else)? But the code never gets inside the foreach.

public partial struct MoveSinusoidalSystem : ISystem
{
    public void OnUpdate(ref SystemState state)
    {
        double deltaTime = SystemAPI.Time.ElapsedTime;
        foreach (var translation in SystemAPI.Query<RefRW<LocalTransform>>().WithAll<MoveSpawnedObject>())
        {
            double yPos = translation.ValueRW.Position.y + 1;
            Debug.LogWarning("print");

            // Apply the movement to the entity
            translation.ValueRW.Position = new float3(translation.ValueRW.Position.x,(float)yPos, translation.ValueRW.Position.z);
        }
    }
}