Megafunk / MassSample

My understanding of Unreal Engine 5's experimental ECS plugin with a small sample project.
MIT License
681 stars 112 forks source link

Mass Entity Collision #29

Closed wtiaw closed 2 years ago

wtiaw commented 2 years ago

Can the Mass Entity has collision?

I try to change ISMC's CollisionProfileName to BlockAll (in MassVisualizationComponent.cpp) but it doesn't work.

vorixo commented 2 years ago

Hello @wtiaw Remember that entities are small unique identifiers that point to a combination of fragments and tags in memory.

If your collision shape is shared across all your entities in your archetype, you could use a Shared Fragment to set your collision data and then engineer collision heuristics in your processors.

The other option you have is to employ real actors with colision for the lowest levels of LOD (using the set of LOD traits) and employ entities for distant objects. My main advice for this is to take a look at the Matrix demo.

Unfortunately adding collision is not a very simple request... But we'll try to ask Epic if it would be possible to offer in-house collisions for raw entities.

vorixo commented 2 years ago

By @wtiaw

I successfully solved this problem with the following three steps:

(in MassVisualizationComponent.cpp)

  1. Set ISMC's CollisionProfileName to BlockAll
  2. Set UE::MassRepresentation::GCallUpdateInstances to 0
  3. Before BatchUpdateInstancesTransforms() call RecreatePhysicsState()
vorixo commented 2 years ago

By @wtiaw

I successfully solved this problem with the following three steps: (in MassVisualizationComponent.cpp)

  1. Set ISMC's CollisionProfileName to BlockAll
  2. Set UE::MassRepresentation::GCallUpdateInstances to 0
  3. Before BatchUpdateInstancesTransforms() call RecreatePhysicsState()

As a side comment to @wtiaw post, we confirmed that this approach would tank down your game time, so be careful with it.