Quantcast
Viewing all articles
Browse latest Browse all 123

Unet: Pass player script component from client to server

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.


Viewing all articles
Browse latest Browse all 123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>