Making a composite entity act like a normal entity
Posted: Wed Dec 25, 2024 8:07 pm
I am making a composite entity and having trouble making it behave like a normal entity for everything that can create and destroy it in the engine. I would appreciate some guidance.
The composite entity comprises a power generator and a crafting machine, which are both assemblers. Players interact with the crafting machine, which is invisible. Players see the power generator and don't interact with it. The power generator can be active at different times than the crafting machine so there's meaningful player feedback in seeing it run.
Scripting composite entities involves letting the engine act on one entity, catching the event, and handling other entities with a script. The approaches I tried had problems:
* If the crafting entity is the main entity that's constructed and deconstructed, then it doesn't produce the expected UI feedback because it is invisible. When the player is about to build it, there is no preview image of the building.
* If the power generator is the main entity that's constructed and deconstructed, players can't deconstruct it because they can't interact after it is built.
* If the power generator is constructible and the crafting entity is deconstructible, then undo and cut-paste don't work. Presumably this is because the engine expects deconstruction and construction to be on the same entity.
How do I make this work?
The composite entity comprises a power generator and a crafting machine, which are both assemblers. Players interact with the crafting machine, which is invisible. Players see the power generator and don't interact with it. The power generator can be active at different times than the crafting machine so there's meaningful player feedback in seeing it run.
Scripting composite entities involves letting the engine act on one entity, catching the event, and handling other entities with a script. The approaches I tried had problems:
* If the crafting entity is the main entity that's constructed and deconstructed, then it doesn't produce the expected UI feedback because it is invisible. When the player is about to build it, there is no preview image of the building.
* If the power generator is the main entity that's constructed and deconstructed, players can't deconstruct it because they can't interact after it is built.
* If the power generator is constructible and the crafting entity is deconstructible, then undo and cut-paste don't work. Presumably this is because the engine expects deconstruction and construction to be on the same entity.
How do I make this work?