Search Unity

Cinemachine and MLAPI

Discussion in 'Cinemachine' started by geek_teach, May 25, 2021.

  1. geek_teach

    geek_teach

    Joined:
    Apr 6, 2021
    Posts:
    1
    I am wanting to get Cinemachine and MLAPI to work together. The problem is that the Player Prefab isn't created until the network spawns it. So, how can I get the CM camera to use the Player as it's target?

    And how can I set up a different Cinemachine camera for each player? Do I add the CM camera as a prefab as well? And like I said in the other question, when the two are created, how do I set them each up to connect to each other?
     
  2. mishakozlov74

    mishakozlov74

    Joined:
    Aug 8, 2018
    Posts:
    143
    Hey, well.

    Why do you need CM for every player? I assume you control only one player, so there is only one camera you need?..
    Other clients don't need to know what others see, am I right?..

    I do work on the same stack, so for now I have one virtual camera looking at the spawn position, and when player connects to the server, I spawn player prefab on both client and server and camera only on client.

    Connecting is trivial, you have a method when you instantiate both. Call GetComponent on Virtual Camera, and set previously instantiated player as target.

    I hope I got you correct though.
     
  3. I actually wish this could be solved somehow. I'm working on a co-op where people can peek at each other. If you played (or saw) Divinity Original Sin (1-2) games, something like that. It can be beneficial to seamlessly merge to another player's established viewpoint (inherently top-down style) in case of "listening in" to conversations. Nothing couldn't be done without it, but we already have Cinemachine for this very purpose.
     
  4. mishakozlov74

    mishakozlov74

    Joined:
    Aug 8, 2018
    Posts:
    143
    But why not create a new vcam with higher priority? You don’t need them constantly?
     
  5. I don't need them constantly, but probably will still do that and try to sync them over the network. In my case the player will be able to hit a button to change their view to one of the other three characters (whether or not they are controlled by other players). Will see how it turns out at the end.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    You could make a prefab that contains both a player and a vcam (as siblings, not descendants), with the vcam's target set to the player.
     
  7. codeBatt

    codeBatt

    Joined:
    Feb 12, 2020
    Posts:
    40
    Hello, I created an empty gameobject under player for camera and cinemachinefreelook. The problem is, whenever new player joins, it only uses the last one's camera. How can I solve this?
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Not sure I fully understand your question. What do you want to happen when you have a player with a camera following it and a new player joins?