Megafunk / MassSample

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

Best way to initialize data for an entity #17

Open OptimisticMonkey opened 2 years ago

OptimisticMonkey commented 2 years ago

What is the best way to initialize different values for an entities fragment?

For example, suppose I want the initial Velocity or Force to be random per entity.

I tired the Trait::BuildTemplate, but this seems to only execute once for all the fragments. Do I have to create custom Spawner?

Thanks for any help/advice ( I am sure I am missing something obvious)

vorixo commented 2 years ago

For a very premature example on how to do this, please check /Game/MassSample/Blueprints/BP_FirstPersonCharacter in the Engine. We have some exposed BP functions that might provide some insight.

Megafunk commented 2 years ago

Spawners are more for 1-off spawns + their positions like NPCs/cars etc rather than spawning new entities with data dynamically. They can be called to spawn stuff whenever but changing their data requires changing their backing entity config AFAIK. We definitely need to nail down the best way to spawn entities dynamically but so far the BP function lib has my best guess.

vorixo commented 2 years ago

Common mass operations section has been added to cover these aspects.