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

Question Cinemachine Selects New PlayerArmatureRoot Every Time a New Player Joins

Discussion in 'Cinemachine' started by Osilidath, Jan 10, 2023.

  1. Osilidath

    Osilidath

    Joined:
    Jun 29, 2022
    Posts:
    16
    My project is all messed up right now so I'm not really sure how to describe this.

    upload_2023-1-10_16-44-47.png

    I have a Menu scene where you choose a class and chosen class saves an integer. Also button changes scene.

    upload_2023-1-10_16-47-44.png

    Also there is a LoadGame object with LoadSystem script which loads the saved integer and selects one of the Cinemachines and deactivates other two. So when I select for example "Warrior" in Menu, my 3rd Person Perspective Cinemachine activates and 1st and Isometric Perspective Cinemachines deactivates.

    I was working on multiplayer and because I won't wanna mix up too much things I deactivated LoadGame object. So I can only work on 1st Person Perspective because I was following a "Multiplayer FPS Tutorial". Everthing were working fine until I have a second player. I made a build and started a host. There were no problems so far.

    upload_2023-1-10_16-59-25.png
    (Host Alone)

    But when run a new ".exe" and start client, Cinemachine flickers and both players focuses on last joined players PlayerArmatureRoot.

    upload_2023-1-10_17-5-14.png
    (Host on the Left, Client on the Right)

    I can control them both seperately, client works as intended, but Host's view is locked at Client's view. I know I can move around Host's PlayerArmatureRoot because gun is child of it. But because Host's Cinemachine is hooked up to Client's PlayerArmatureRoot and not Host's, Host can't actually look around. For example if I press W from Host in the scenario above, even though host armature itself is "looking" at Client, it will move towards to red wall. Because it is actually looking towards red wall. It is hard to explain as it is hard to understand.

    I just followed some simple tutorials. Don't know much about Unity. Followed tutorials:





    Also because I don't have a character in the hierarchy anymore, I can't select the Cinemachines in the LoadSystem script. They were embedded into the Player Prefab. If I get them out of prefab I can't select their "Follow" and "Look At" variables as "PlayerArmatureRoot".

    Any help is appreciated. Thanks.
     
    Last edited: Jan 10, 2023
  2. Osilidath

    Osilidath

    Joined:
    Jun 29, 2022
    Posts:
    16
    I forgot to show my Cinemachine options, so here are they.

    upload_2023-1-10_17-45-14.png
     
  3. Osilidath

    Osilidath

    Joined:
    Jun 29, 2022
    Posts:
    16
    I solved this problem but now I got a different problem.

    I simply moved Cinemachines out from prefab to hierarchy and both problems solved.

    But now for example I started host as 3rd person and add a client 1st person, because clients code ran later, 3rd person camera gets deactivated so host does not have a Cinemachine anymore. What I want is, I want this this changes to done only locally. Should I use ClientRpc and spawn these cameras instead of activating/deactivating them?
     
  4. Osilidath

    Osilidath

    Joined:
    Jun 29, 2022
    Posts:
    16
    My other problem solved by itself. I don't know how did it happen, but I don't have that issue for now. And I hope I don't have anymore either.