Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Properly set up third person camera in multiplayer

Discussion in 'Multiplayer' started by Koolaps, Aug 23, 2017.

  1. Koolaps

    Koolaps

    Joined:
    Dec 28, 2014
    Posts:
    6
    Hi everyone,

    Right now I'm working on third person view implementation in multiplayer, I want to know if I'm doing it right, here's how it work for now :

    I have a prefab named "Player" which has as child the "Pivot" component who has himself as child the Camera.

    So, basicaly Player -> Pivot -> Camera

    I did that as I want to spawn all component needed together.

    I have put scripts like controller, motor, rigibody, network view, network transform etc only on the "Player" component.

    When my player is spawned, the child Pivot is detached from the player so I can control it rotation with the mouse and turn the camera arround my player.

    I did that as I want to control my player with the camera, she's free and turn arround him and when I push forward the player turn to the direction where my camera look at and he move forward, but if my camera is still attached as a child of the player it don't work because she will turn with him.

    As the pivot component can't have network view (only one per prefab) when the player is disconnected I have a script attached to the "Pivot" component to destroy it.

    All of this work correctly, I tested it, but I wonder if there's a better way to do it, I tried to find some documentation about it but without success.

    Am I doing it correctly ?