SushiEngine::Simulation::IEntityBehavior
on_spawn
Message: the engine calls this function.
virtual void on_spawn(IWorldEditor &world, EntityId id)Parameters
| Name | Type | Description |
|---|---|---|
world | IWorldEditor & | |
id | EntityId | This instance's own entity. |
Description
Runs once, when this instance first exists: at the start of Play, or when add_script_component attaches the script during Play.
Example
void on_spawn(SushiEngine::Simulation::IWorldEditor& world,
SushiEngine::Simulation::EntityId id) override
{
const SushiEngine::Simulation::ScriptComponent script =
world.script_component(id, "SpinningLight");
for (const SushiEngine::Simulation::ScriptField& field : script.fields)
{
if (field.name == "speed")
speed_ = field.number;
}
}

