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

Question How to keep 1 target centered, 1 in a dead zone, and allow movement?

Discussion in 'Cinemachine' started by mnoah98, Apr 6, 2023.

  1. mnoah98

    mnoah98

    Joined:
    Jul 15, 2013
    Posts:
    6
    I'm trying to make a camera that will always keep the player centered, and always rotate around the player. When a key is held, it will rotate to keep the enemy inside the dead zone.

    camera.png
     
  2. marc_tanenbaum

    marc_tanenbaum

    Unity Technologies

    Joined:
    Oct 22, 2014
    Posts:
    637
    I'd suggest simply creating two virtual cameras, one for each case. When the key is pressed, swap the priority level. Cinemachine will automatically blend between them.
     
  3. mnoah98

    mnoah98

    Joined:
    Jul 15, 2013
    Posts:
    6
    I don't think Cinemachine has a camera for the bottom part of my example. I can almost achieve it by making a Virtual Camera and setting the Follow to the player, and the Look At to the target. But it won't let me do this AND allow the mouse to move it around.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    You are right, there is nothing built-in to do precisely this. The closest you can come is to use a CinemachineTargetGroup that holds the player plus the lock-on enemy. Use the group as a LookAt and Follow Targets, and put OrbitalTransposer in Body, and GroupComposer in Aim. That will put the group members within the dead zone, but there is no code to center the player. Increasing the groups weight of the player might help.