static function Instantiate (prefab : Object, position : Vector3, rotation : Quaternion, group : int) : Object
Description
Network instantiate a prefab.
The given prefab will be instanted on all clients in the game. Synchronization is automatically set up so there is no
extra work involved. The position, rotation and network group number are given as parameters. Internally this is an
RPC call so when Network.RemoveRPCs is called for the group number, the object will be removed. Note that there must
be something set to the playerPrefab in the Editor. You can read more about instantiations in the object reference Object.Instantiate.
var playerPrefab :
Transform;
function OnConnectedToServer () {
Network.Instantiate(playerPrefab, transform.position, transform.rotation, 0);
}
using UnityEngine;
using System.Collections;
public class example :
MonoBehaviour {
public Transform playerPrefab;
void OnConnectedToServer() {
Network.Instantiate(playerPrefab, transform.position, transform.rotation, 0);
}
}
import UnityEngine
import System.Collections
class example(
MonoBehaviour):
public playerPrefab as
Transform def OnConnectedToServer():
Network.Instantiate(playerPrefab, transform.position, transform.rotation, 0)