networkView for first person controller

Is there a simple way to apply networkView.isMine to an instantiated first person controller? Do I need to go through all the code to add this to both the camera and characterMotor ect.? I tried creating a script and applying it to my player and the camera for the prefab but that didn’t work.

function Start () {

    if(!networkView.IsMine)
    enabled=false;
    
    }

I don’t know if I understand correctly what you’re trying to do and what exactly is the problem.
What exactly doesn’t work? And are there any error messages in the console?

My assumption is that you want to avoid having to apply the same code to every single child object separately, right?
If so, I guess that there isn’t really another way, but this makes some sense in my opinion: You do not naturally want to apply exactly the same logic to all related child objects.

E.g.: If you apply the above script as is to both the player object and the camera, be aware that it will disable the complete player script on other connected clients as well. Is this intention? It definitely makes sense for the camera and the CharacterMotor scripts, but probably not for the script attached to your (root) player object, because in there might also be logic that needs to be run on other clients as well.

Apart from that: If you use the above script as is, every single object to which it is attached needs to have its own networkView, including the camera. You could try to avoid this by attaching only one Network View to the parent game object and then change the script in child objects to something like this:

1.function Start () {
2. 
3.    if(!root.networkView.IsMine)
4.    enabled=false;
5.    
6.    }

But I am still uncertain whether this covers your question/problem.

When I spawn ( instantiate) each player onto the server I want each to be able to control their own character. Which is just all the components of the first person controller. So right now when both players spawn in both are controlled while controlling either of the chartacters. I want each player to control their own player / camera. That code just gave me an error for root.

  • What are the configurations of the Network View in the inspector window?
  • Have you run the Monodevelop debugger to check the state of “networkView” in your code during runtime?