Question by
Baglison · Dec 22, 2017 at 05:49 PM ·
c#instantiatescript.multiplayer-networkingparameters
Network.Instantiate passing parametrs to instantiated object, unassigned reference exception
Hi guys, I'm making a multiplayer game using Unity's HLAPI. I'm doing everything pretty much analogically to this: (https://unity3d.com/…/multipla…/adding-multiplayer-shooting…). Atm I'm making a shooting mechanic, and my bullet spawning script looks roughly like that:
GameObject bullet = Network.Instantiate(bulletPrefab, barrelEnd.position, barrelEnd.rotation)
as GameObject;
bullet.GetComponent<BulletController>().ownerGameObject = this.gameObject;
bullet.GetComopnent<Rigidbody>().velocity = velocity;
NetworkServer.Spawn(bullet);
And while testing, I constantly receive "Unassigned reference exception" on BulletController.ownerGameObject. How should I fix it? Thanks in advance :p
Comment