Ok so no one ever replied to my post. Maybe because I replied that I had a working alternative, but as I said, I didn’t think it was a clean way to do it. Well through persistence and determination it came to me when I was on the toilet, oh I mean on the phone with my son :J complaining to him how Unity networking works and it occurred to me how to resolve it. It was so obvious. Serves me right for following examples instead of looking to do it the way I know how to do it on other platforms.
I mentioned earlier that on other platforms I’d usually be able to send a network packet with additional information, so I could include what I need in the originating packet, but using Network.Instantiate didn’t support that. What I realized was instead of using Network.Instantiate I could use an rpc and do it all from there.
Originally I was running Network.Instantiate(go_missle, transform.position, transform.rotation,0); My issue was that with this command I couldn’t send any additional information such as who was the parent object, or any other information I might need. What I thought to do was first issue the Network.Instantiate then use an RPC call to pass the information after it was instantiated. As I was thinking through it I realized I could use the RPC for everything including the instantiate, and didn’t need to use Network.Instantiate at all. This way I can use a single command and send the extra information needed. See below for the details of what I did.
So the fix is as follows:
if (TimeToFire >= refire_rate_in_seconds Input.GetMouseButtonUp(1) )
{
NetworkViewID _vid = Network.AllocateViewID();
networkView.RPC( “OnFireMissile”, RPCMode.AllBuffered, _vid, this.networkView.viewID);
}
[RPC]
void OnFireMissile (NetworkViewID _viewId, NetworkViewID _parentViewId)
{
GameObject theMissle = Instantiate(go_missle, transform.position, transform.rotation) as GameObject;
NetworkView nview = (NetworkView)theMissle.GetComponent(typeof(NetworkView));
nview.viewID = _viewId;
if (nview.isMine)
{
NetworkRigidbody _NetworkRigidbody = (NetworkRigidbody) theMissle.GetComponent(“NetworkRigidbody”);
_NetworkRigidbody.enabled = false;
}
else
{
name += “Remote”;
NetworkRigidbody _NetworkRigidbody = (NetworkRigidbody) theMissle.GetComponent(“NetworkRigidbody”);
_NetworkRigidbody.enabled = true;
}
// Both the Player has a subobject for the ship which has a collider and the missle has a subobject for the capsule which has a collider
Physics.IgnoreCollision(transform.GetChild(0).collider, theMissle.transform.GetChild(0).collider); // don’t collide with ourselves
}