Unet Spawn System

Hello there i explain it as simple as i can. I need my player to spawn a rocket in his launcher and to update it so all players can see that there is a rocket. And on a click to fire it. How would i go about doing that any tutorial any suggestions. oh Yes i am using the new UNET system.

Well I’m not 100% positive this will work with the new UNET system but it should. Put this into where you want to fire the rocket. E.G. Input.GetMouseButtonDown(0).

Ok first you need to add your rocket that is going to be fired here:

var rocket:GameObject;

then you want to have a variable of an empty that will be where the rocket spawns:

var rocketSpawnPoint:Transform;

also I’m gonna note that you drag your rocket object AS A PREFAB into the “rocket” variable.
and this is the code that will be under where you want to fire it in Update.

Network.Instantiate(rocket, rocketSpawnPoint.position, rocketSpawnPoint.rotation, 0);

And make sure that your rocket has a NetworkView on it.

thx for the reply but that doesnt work with the new unet system

Ok, you need to put a network Indentity and network transform.

and put this inside your getButton fire 1… CmdFire() like this

[SerializeField]public GameObject bulletObject;
public Transform bulletSpawn;
public float fireRate ;
private float nextFire ;	
void Update(){
if (Input.GetButton ("Fire1")&&Time.time > nextFire) {
				CmdFire ();
				playerSource.PlayOneShot (defalutSound);
				nextFire =  Time.time + fireRate;
    	void CmdFire(){
    		GameObject clone=(GameObject)Instantiate(bulletObject,bulletSpawn.transform.position,bulletSpawn.transform.rotation) ;
   clone.GetComponent<Rigidbody>().velocity = bulletSpawn.transform.TransformDirection (Vector3.forward * Speed);
NetworkServer.Spawn (clone);

And you should be good, Also, don’t forget to put your prefab inside your NetWorkManager SpawnInfo