SpawnSharedEntity ( prefab_id$[,parent] )

Parameters

prefab_id$ - id of a required model asset in the shared world, such as "crate", or "entity:" and the id of an entity of the world, whose look is copied, such as "entity:crate"

parent (optional) - entity to create it under, such as an entity from the world; 0 for none (default)

Description

Creates a shared prop from a model asset, on the host.

Use it for things that appear during the game - a crate, a pickup, a projectile. It is created in every player's world, and the host's copy is in charge: move it, animate it and simulate its physics on the host, and the others see it follow.

Returns the new entity, or 0 with the reason in SharedWorldError(). The session must be ready (SHARED_READY). Only the host can spawn shared props; a client asks the host with SendSharedMsg. The asset must be a required model asset of the world; an "entity:" prefab copies how one of the world's own objects looks, shown and with no behaviours or physics. Players who join later receive it too.

FreeEntity on the host removes it everywhere.

For the full story - services, hosting, sharing and host migration - see the Shared World guide and its complete Shared_World_Playground.bb sample.


See also: SpawnSharedPlayer, ShareWorldEntity, UnshareEntity, SharedEntityID, SendSharedMsg.

Index