- Home /
NetworkWriter GameObject has no NetworkIdentity
I'm trying to spawn weapons on all the players in their hands in the scene. But Mirror won't allow me to parent the weapon to the character's holster gameobject (an empty gameobject on the hips). AFAIK it should be a ClientRpc function because I want all clients and server to see the weapons they are all holding.
public GameObject weaponPrefab = null;
public GameObject mainHandHolster = null;
public override void OnStartAuthority () {
CmdSpawnWeapons();
}
[Command]
private void CmdSpawnWeapons (NetworkConnectionToClient _sender = null) {
GameObject _weapon = Instantiate(weaponPrefab, transform.position, Quaternion.identity);
_weapon.transform.parent = transform;
NetworkServer.Spawn(_weapon);
RpcSetParent(_weapon, MainHandHolster);
}
[ClientRpc]
private void RpcSetParent (GameObject _object, GameObject _parent) {
_object.transform.parent = _parent.transform;
}
It gives an error that the parent is null:NetworkWriter REF Main-hand holster (UnityEngine.GameObject) has no NetworkIdentity
Adding NetworkIdentity to the Main Hand Holster reference makes no sense to me and even if I do, Mirror yells at me for having multiple NetworkIdentity's.
Your answer
Follow this Question
Related Questions
MIRROR: Connect Android client to PC server? 2 Answers
Mirror: Can't connect to Oculus Quest 2 (Android) Host - Instant Disconnect 1 Answer
Oculus VR with Mirror multiplayer - headset is controlling both players 1 Answer
Get the device IP address from Unity 3 Answers
Mirror NetworkServer.Spawn doesn't spawn stuff on Clients 2 Answers