DOTS: Proper way to destroy an Entity?

Hello gang,

I have an ITriggerEventsJob when the player collides with other entities, causing the other entity to be blown up. So obviously I need to destroy that entity, and so far all I have seen is by using the Entity Command Buffer:

entityCommandBuffer.DestroyEntity(entity);

My question is; what is the proper way to destroy an entity?

Thanks

There’s no proper way. It’s case to case basis. ECB.DestroyEntity() is totally proper. But in some cases, you may not want this because you’d want some subsequent systems to still be able to query this entity and do something. You can do stuff like adding a component or an IEnableableComponent and have a system handle the entity destruction. This is totally up to your requirements.

2 Likes

Thank you, that was helpful.

Have a great weekend

1 Like