Setting LocalTransform makes entity not visible

Sigh. I HATE these moments. I don’t know why, but now It works. ¯_(ツ)_/¯

This works, for what it’s worth considering the source

float3 position = new float3(1985, layer, -1200); 
           
var localTransform = LocalTransform.FromPositionRotation(position, quaternion.identity);
entityCommandBuffer.SetComponent(entity, localTransform);

Ok,

Welcome back to “James is doing something stupid”

I have narrowed down the problem I have when I instantiate some objects when the game starts.

int index = randomComponent.ValueRW.random.NextInt(0, trafficSpawnerComponent.Length);
Entity spawnedEntity = EntityManager.Instantiate(trafficSpawnerComponent.ElementAt(index).prefab);

float3 position ;
position.y = 70;
position.z = -1200;
position.x = 1985;

var localTransform = LocalTransform.FromPositionRotation(position, quaternion.identity);

//ANY OF THESE CAUSE THE ENTITY TO DISAPPEAR
//entityCommandBuffer.SetComponent(spawnedEntity, new LocalTransform { Position = position });      //entityCommandBuffer.SetComponent(spawnedEntity, localTransform);
//entityCommandBuffer.SetComponent(spawnedEntity, new LocalTransform { Position = position, Rotation = new quaternion(), Scale = 1.0f });

Within the Entities Hierarchy the entity’s values are visible and set correctly:

Imgur

This is a simple sphere and unlit material. Again, if I run this without attempting to set its position, the entity is visible in game and scene views.

So… what dumbass thing am I doing wrong?

Thanks

On Line 14 of your example, you should set the Rotation to quaternion.identity.
Even though I am not on the 1.0 Transform version, I can imagine a zeroed quaternion can result into an “invalid” transform matrix which can’t be rendered.

 Entity instance = state.EntityManager.Instantiate(spawner.ValueRO.Prefab);
                            //ecb.AddComponent(instance, new Parent { Value = entity });
                            ecb.AddComponent(instance, new LocalTransform
                            {
                                Position = SystemAPI.GetComponent<LocalToWorld>(entity).Position,
                                Rotation = quaternion.identity,
                                Scale = SystemAPI.GetComponent<LocalTransform>(spawner.ValueRO.Prefab).Scale
                            });

Hopefully this helps. You have to use LocaltoWorld. If you set a parent you don’t need any positions.

I will look into this, thank you kindly.