public void Spawn()
{
spawned = true;
Transform spawn = spawns[Random.Range(0, spawns.Length)];
GameObject pl = PhotonNetwork.Instantiate(PlayerPrefs.GetString("class"), spawn.position, spawn.rotation, 0) as GameObject;
if (pl != null)
{
characterControls cc = pl.GetComponent<characterControls>();
cc.enabled = true;
cc.fpsCam.SetActive(true);
cc.head.gameObject.SetActive(false);
cc.mesh.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly;
foreach(MeshRenderer accessory in cc.accessories)
{
accessory.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly;
}
cc.pv.RPC("setName", PhotonTargets.AllBuffered, PhotonNetwork.playerName);
cc.pv.RPC("setPFP", PhotonTargets.AllBuffered, profilePicURL);
}
}
GameObject botToSpawn;
public void spawnBot(string nm)
{
if (GameObject.Find("_Network").GetComponent<PhotonView>().isMine)
{
foreach(GameObject bt in botAi)
{
if(bt.name == nm)
{
botToSpawn = bt;
}
}
What game is this forMe.
Here's some code from a game of mine.. which is in c#
Code:public void Spawn() { spawned = true; Transform spawn = spawns[Random.Range(0, spawns.Length)]; GameObject pl = PhotonNetwork.Instantiate(PlayerPrefs.GetString("class"), spawn.position, spawn.rotation, 0) as GameObject; if (pl != null) { characterControls cc = pl.GetComponent<characterControls>(); cc.enabled = true; cc.fpsCam.SetActive(true); cc.head.gameObject.SetActive(false); cc.mesh.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly; foreach(MeshRenderer accessory in cc.accessories) { accessory.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.ShadowsOnly; } cc.pv.RPC("setName", PhotonTargets.AllBuffered, PhotonNetwork.playerName); cc.pv.RPC("setPFP", PhotonTargets.AllBuffered, profilePicURL); } } GameObject botToSpawn; public void spawnBot(string nm) { if (GameObject.Find("_Network").GetComponent<PhotonView>().isMine) { foreach(GameObject bt in botAi) { if(bt.name == nm) { botToSpawn = bt; } }