switch camera to follow from a character to another one
Hi! I have this script in my camera for a 3D turn based board game:
public GameObject Player1, Player2;
private Vector3 offset;
void Start () {
offset = transform.position - Player1.transform.position;
offset = transform.position - Player2.transform.position;
}
void LateUpdate()
{
transform.position = Player1.transform.position + offset;
transform.position = Player2.transform.position + offset;
}
It's ok for one character to follow it around the playfield, but the thing is I want, when it's turn is over, that the camera starts to follow another character. I don't know how to do it. I would appreciate any ideas to do that. Thanks!
Answer by UnityCoach · Oct 01, 2018 at 10:34 PM
You want to use either Cinemachine, or Constraints.
Can I use Cinemachine as an in-game camera? I thought it was only for cut-scenes or cinematics.
Cinemachine is a virtual Cameraman, you tell it what to "frame", from where, what to avoid, and so on. It definitely is great for In-Game as it can also switch from a Camera to another based on "Shot Evaluation". So if the subject is impossible to catch from a given angle, you can transition to another, and many, many other options.
Thanks for the answer, now I'm trying out Cinemachine and it looks promising. One more thing to get what I want: I'm seeing that a State-Driven Camera is what I need, but I can only put an Animated Target. Is there a way to put more targets and change them at my pleasure or should I make a Driven Camera for each target?
Your answer
Follow this Question
Related Questions
camera not following target after reload 0 Answers
Camera always behind player 0 Answers
Camera zoom out on follow 1 Answer
How can I make a third person camera collision script? 2 Answers