I set it up so you spawn in with a UI and you choose your team and class, once that is done I want you to be able to spawn with that team and class, however I need to make that prefab turn into my local player so I can effect other scripts on it saying only do this to the local player that of course being the prefab so this script will work.
using UnityEngine;
using System.Collections;
using UnityEngine.Networking;
public class Shoot : NetworkBehaviour {
public int BulletSpeed = 300;
public GameObject ObjectToSpawn;
public GameObject SpawnPoint;
public GameObject Cam;
public GameObject Player;
public string nameTag;
void Start() {
if (!isLocalPlayer) {
return;
} else {
CmdStarter ();
}
}
[Command]
void CmdStarter() {
Bullet.shooterName = "" + nameTag;
}
private void Update() {
if (!isLocalPlayer) {
return;
}
if (Input.GetKeyDown (KeyCode.Mouse0)) {
CmdSpawnMyCrap ();
}
}
[Command]
void CmdSpawnMyCrap() {
GameObject objectSpawned = (GameObject) Instantiate (ObjectToSpawn);
objectSpawned.transform.position = SpawnPoint.transform.position;
objectSpawned.transform.Rotate (Cam.transform.rotation.x, Player.transform.rotation.y, 0f);
objectSpawned.GetComponent<Rigidbody> ().AddForce (Cam.transform.forward * BulletSpeed, ForceMode.Impulse);
NetworkServer.Spawn (objectSpawned);
}
}