NetworkView component issue

hello,

I have a ‘Player’ prefab which contains a ‘NetworkView’ component, within the ‘Player’ prefab, i have ‘Player’ → ‘Main Camera’ → ‘Launcher’. On the ‘Launcher’ gameobject, I also have a ‘NetworkView’ component attached to it. So, when I start the game, the ‘Player’ is instantiated, everything is fine - no errors. Then, when I connect as client in another window, the ‘Player’ is instantiated but I get this error:

View ID AllocatedID: 151 not found during lookup. Strange behaviour may occur
Received state update for view id’ AllocatedID: 151’ but the NetworkView doesn’t exist

If I keep clicking trying to launch my ‘rocket’, the error constantly pops up with incrementing view ID’s

Here is my ‘WeaponLauncher.cs’ file that is attached to the ‘Launcher’ gameobject within the ‘Player’ prefab:

using UnityEngine;
using System.Collections;

public class WeaponLauncher : MonoBehaviour {
	public Rigidbody projectile;
	Rigidbody instantiatedProjectile;
	float speed = 20.0f;
	
	// Use this for initialization
	void Start () {
	
	}
	
	void HandleMouseEvents(){
		if(Input.GetMouseButtonDown(0)){

			if(networkView.isMine)
        	{
				NetworkViewID viewID  = Network.AllocateViewID();

				networkView.RPC("SpawnMissile", RPCMode.All, transform.position, transform.rotation, transform.forward * speed, viewID);
			}
		}
	}
	
	[RPC]
	void SpawnMissile(Vector3 position, Quaternion rotation, Vector3 force, NetworkViewID viewID)
	{
		
		instantiatedProjectile = (Rigidbody)Instantiate(projectile, position, rotation);
		instantiatedProjectile.AddForce(force, ForceMode.Impulse);
		
	    instantiatedProjectile.networkView.viewID = viewID;
		Physics.IgnoreCollision( instantiatedProjectile.collider, transform.root.collider );
	}
	
	// Update is called once per frame
	void Update () {
		HandleMouseEvents();
	}
}

Here is the ‘Rocket.cs’ file that is attached to the projectile that the ‘WeaponLauncher.cs’ script instatiates:

using UnityEngine;
using System.Collections;

public class Rocket : MonoBehaviour {
	
	Vector3 remoteVelocity;
	Vector3 remoteLocation;
	Quaternion remoteRotation;
	
	// Use this for initialization
	void Start () {
		
	}
	
	void FixedUpdate()
	{
	    if(networkView.isMine)
	    {
	        remoteVelocity = rigidbody.velocity;
	        remoteLocation = rigidbody.position;
	        remoteRotation = rigidbody.rotation;
	    } else {
	        rigidbody.velocity = remoteVelocity;
	        rigidbody.position = remoteLocation;
	        rigidbody.rotation = remoteRotation;
	    }
	}
	
	void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info) {
	    stream.Serialize(ref remoteVelocity);
	    stream.Serialize(ref remoteLocation);
	    stream.Serialize(ref remoteRotation);
	}
}

nevermind, fixed.

It’s that all player’s gameObject is visible?

It should of been this:

using UnityEngine;
using System.Collections;

public class WeaponLauncher : MonoBehaviour {
	public Rigidbody projectile;
	Rigidbody instantiatedProjectile;
	float speed = 40.0f;
	
	// Use this for initialization
	void Start () {
	
	}
	
	void HandleMouseEvents(){
		//if(Input.GetMouseButtonDown(0)){
		if (Input.GetKeyUp("f")){

			if(networkView.isMine)
        	{
				NetworkViewID viewID  = Network.AllocateViewID();
				networkView.RPC("SpawnMissile", RPCMode.All, transform.position + transform.forward * 0.7f, transform.rotation, transform.forward * speed, transform.networkView.viewID);
			}
		}
	}
	
	[RPC]
	void SpawnMissile(Vector3 position, Quaternion rotation, Vector3 force, NetworkViewID viewID)
	{
		
		
		instantiatedProjectile = (Rigidbody)Instantiate(projectile, position, rotation);
		instantiatedProjectile.AddForce(force, ForceMode.Impulse);
		
		//NetworkView nView = instantiatedProjectile.GetComponent<NetworkView>();
		NetworkViewID nView  = Network.AllocateViewID();
		projectile.networkView.viewID = nView;

		Physics.IgnoreCollision( instantiatedProjectile.collider, transform.root.collider );
	}
	
	// Update is called once per frame
	void Update () {
		HandleMouseEvents();
	}
}

Oh, So that make sure the projectile has same networkviewid.