Using LookAt to look at a Vector3 not Transform
Hey! So I'm writing a camera script that is designed to follow a player around while keeping the opponent in view. My goal is to have the camera hang out "behind" the player (meaning there is a straight line between the opponent, player and camera) while keeping the rotation focused on the midpoint between the player and the opponent.
I got the positioning working, but I can't figure out how to get the rotation to work. My problem is that LookAt seems to require a Transform target, but I wanted to use the point calculated by halving the vector between the player and opponent and adding it to the player's position. Since this would be a Vector3 and not a Transform, I'm a bit stuck (trying to avoid doing my own trig haha).
I'm also still very new to unity, so if anyone has some explanation/resources I could use to figure out why LookAt would even use a Transform instead of a Vector3 as its target I'd appreciate it!
transform.LookAt
comes in few variants and Vector3
-related is certainly among them ( transform.LookAt( Vector3.zero );
works fine)
Oh whoops, I guess I need to get better at reading the documentation... Thanks!
I suggest you just use any code editor with intellisense support for c#. Visual Studio or VSCode (hip, lite version).
Your answer
Follow this Question
Related Questions
First person camera flipping by looking up or down too far. 1 Answer
Why object's doesn't stop on collision enter? 0 Answers
Framing multiple objects from a list along y axis only? 0 Answers
I'm trying to transfer the display from my phone camera to my computer (Realtime!) 0 Answers
Boolean variable is never true, even if declared true or ticked in the inspector 1 Answer