Unity ECS, Initialize a PhysicsColliderKeyEntityPair buffer

189 Views Asked by At

I have an entity with multiple PhysicsCollider that RaiseTriggerEvents only.

I think I cannot have a child entity that contains a PhysicsCollider IComponentData, so I think I have to use PhysicsColliderKeyEntityPair.

How do we initialize a PhysicsColliderKeyEntityPair?

Here is what I got so far, I am stuck at ColliderKey!

Class

public class PrefabsConverter : MonoBehaviour, IDeclareReferencedPrefabs, IConvertGameObjectToEntity

The code

 var colliderBuffer = em.AddBuffer<PhysicsColliderKeyEntityPair>(thisEntity);

 for (int a = 0; a < enemyComponent.damagableProfile.values.Count; a++)
 {
      var collider = new PhysicsCollider() { Value = enemyComponent.damagableProfile.values[a].ToCollider() };

      colliderBuffer.Add(new PhysicsColliderKeyEntityPair() { Entity = thisEntity, Key = new ColliderKey(???) });
 }
0

There are 0 best solutions below