๐ฎ Spawning
Overviewโ๏ธ
Omni supports spawning objects on both the server and client, providing several methods for network object instantiation. In this guide, weโll walk you through the available options, from the simplest to the most advanced approaches, enabling you to choose the best method based on your projectโs requirements.
Each method allows for a different level of control over networked objects, from basic automatic spawning to more complex, customizable instantiation processes.
Simple Instantiationโ๏ธ
The Network Identity Spawner component provides a quick and efficient way to instantiate networked objects, making it ideal for prototyping stages. This component simplifies the process by automatically handling the instantiation of both prefabs and scene objects over the network.
With Network Identity Spawner, you can set up networked objects with minimal configuration, allowing you to focus on testing gameplay and mechanics rather than complex network setups.
- Add the
Network Identity Spawner
component to any game object in your scene.
Field | Description |
---|---|
Local Player | A NetworkIdentity reference for the object that will be controlled by the local player. This object will receive input and commands directly from the local player. |
Identities to Spawn | A list of NetworkIdentity references for objects to be managed by the server. These objects will be instantiated over the network and controlled by the server. |
Using this setup, the Network Identity Spawner
manages instantiation and synchronization, simplifying networked spawning for both player-controlled and server-managed objects.
Object Assignment Flexibility
- Local Player: Can be assigned either a prefab or scene object that will be controlled by the local player
- Identities to Spawn: Accepts both prefabs and scene objects that need network synchronization
- Each object must have a NetworkIdentity component attached
- This component is designed for rapid prototyping only and should not be used in production environments
Manual Instantiationโ๏ธ
If you want to instantiate a networked object manually in a straightforward way, here are some examples to guide you. Manual instantiation provides you with more control over when and where the networked object appears in the scene, ideal for scenarios where specific logic or conditions dictate object creation.
Follow these examples to quickly and easily get started with manual instantiation of networked objects in your project.
First example:
Tip
NetworkManager.GetPrefab
offers two overloads: one for retrieving a prefab by its name and another for accessing a prefab by its index in the registered prefab list.prefab.Spawn
offers two overloads and optional arguments to control the spawn process.
Check de API reference for more details.