Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Problem with children objects and networking

Discussion in 'Multiplayer' started by Lyro_1, Nov 27, 2016.

  1. Lyro_1

    Lyro_1

    Joined:
    Nov 27, 2016
    Posts:
    7
    Hello guys !

    I'm currently working on a multiplayer game project, in which you will be able to drive some jeeps or buggys to kill other players. I wanted to directly work on a multiplayer version of the game, so I created a CarController script (in C#) to controll the car (speed, direction). But, I'm in front of a big problem :
    I have an empty called car, with the car model and a camera, which have a network identity, without network transform, and I simply make this script only related to the local player by adding a condition at the beginning of the Update() function :

    if (!isLocalPlayer) {
    return;
    }
    //rest of the update function

    But the problem is that my car have a turret, to shoot, and a camera behind the car, which is a MainCamera for the Localplayer. But the main problem is that those two objects are children of the car empty, which have the networkidentity. And if I make my scripts TurretController and CameraController "NetworkBehaviour", it says that it cannot work because those objects are children of the car empty...

    So all the players can turn all the cameras and all the turrets... That's annoying :/

    Does anyone could help me ? If you need any precision, please tell me !

    Thanks :)
     
  2. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,325
    You probably need one NetworkIdentity on your car, and then add a script to it that controls the car, the turrets, etc.
     
  3. Lyro_1

    Lyro_1

    Joined:
    Nov 27, 2016
    Posts:
    7
    I will try it :)