I’m running into an issue where entities do not render if I create an entity and add the PhysicsVelocity component programmatically.
I am currently re-using an existing collider & other physics components from an entity converted from a prefab. The physics for the prefab does work.
Prefab:
Generation code
void Start()
{
sharedTemplate = ConvertGameObjectHierarchy(
root: sharedColliderPrefab,
settings: World.Active
);
cachedCollider = entityManager
.GetComponentData<PhysicsCollider>(sharedTemplate)
.Value;
cachedPhysicsMass = entityManager.GetComponentData<PhysicsMass>(sharedTemplate);
cachedPhysicsDamping = entityManager.GetComponentData<PhysicsDamping>(sharedTemplate);
....
}
var entity = entityManager.CreateEntity();
entityManager.AddComponent(entity, typeof(LocalToWorld));
entityManager.AddComponent(entity, typeof(Rotation));
entityManager.AddComponentData(entity, new Scale { Value = 0.9f });
entityManager.AddComponentData(entity, new Translation
{
Value = new float3
{
x = x - voxelHalfDepth,
y = y - voxelHalfDepth
}
});
entityManager.AddComponentData(entity, cachedPhysicsMass);
entityManager.AddComponentData(entity, cachedPhysicsDamping);
entityManager.AddComponentData(entity, new PhysicsVelocity
{
Angular = float3.zero,
Linear = float3.zero
});
entityManager.AddComponentData(entity, new PhysicsCollider
{
Value = cachedCollider
});
entityManager.AddSharedComponentData(entity, new RenderMesh
{
mesh = mesh,
material = material
});
What’s interesting is that if I use either the prefabs PhysicsVelocity or a new PhysicsVelocity, nothing shows up and these are the component values.

But if I remove the PhysicsVelocity, then the values are okay and the boxes do show up. (But they don’t fall)


