Hi guys,
I'm trying to pass the PlayerController script to the spawned bullet to determine the next turn after it hit something. Players are always a client and server is the gameserver that it hosted somewhere else.
Playerscript has this command but it does not pass it: CmdFireBullet(gameObject); [Command] private void CmdFireBullet(GameObject _gameObject) { bullet = (GameObject) Instantiate(bulletprefab); bullet.GetComponent ().AddPlayer (_gameObject.GetComponent());
NetworkServer.Spawn (bullet);
}
Bulletscript (is owned by Server) public List playerList = new List();
public void AddPlayer(PlayerController pc)
{
playerList.Add(pc);
}
However if the client acts as a server and I use this "ball.GetComponent ().AddPlayer (this);" in commad it passes on both side.
I'm trying to pass the PlayerController script to the spawned bullet to determine the next turn after it hit something. Players are always a client and server is the gameserver that it hosted somewhere else.
Playerscript has this command but it does not pass it: CmdFireBullet(gameObject); [Command] private void CmdFireBullet(GameObject _gameObject) { bullet = (GameObject) Instantiate(bulletprefab); bullet.GetComponent
Bulletscript (is owned by Server) public List
However if the client acts as a server and I use this "ball.GetComponent ().AddPlayer (this);" in commad it passes on both side.