how to add physics component to an entity programmatically
Because the physics collider of the dots physics package don’t implement IComponentData they can’t be added with the standard AdComponentData from the entity manager so this snippet demonstrates how to cimcumbert this by using a ComponentType array as some sort of archetype declaration.
EntityManager entityManager = World.DefaultGameObjectInjectionWorld.EntityManager; ComponentType[] componentTypes = new ComponentType[3]; componentTypes[0] = typeof(PhysicsCollider); componentTypes[1] = typeof(TranslationProxy); componentTypes[2] = typeof(RotationProxy); Entity entity = entityManager.CreateEntity(componentTypes); BlobAssetReference<Unity.Physics.Collider> spCollider = Unity.Physics.SphereCollider.Create(float3.zero, 2f); entityManager.AddComponentData(entity, new Translation { Value = float3.zero }); entityManager.AddComponentData(entity, new Rotation { Value = quaternion.identity }); entityManager.SetComponentData(entity, new PhysicsCollider { Value = spCollider });












