- Home /
Question by
Michelmk · Nov 23, 2015 at 12:55 PM ·
cameracamera-looktargetinglocking
Player camera targeting/locking another object
I am developing a game that uses a third person camera view, character centralized, no issues with that. But I can't find a way to "lock" on another object while keeping my character in view (Rocket League ball cam: https://youtu.be/FDcO04gXihM ).
I am aware of lookAt() method but it's not enough on its own. I still need to calculate the position of the camera to avoid staying between the player and the target. The problem: http://imgur.com/a/MdO9m
This is what I'm currently doing to move the camera (the "free cam"):
if (freeCam) {
transform.position = Vector3.Lerp(transform.position, camTarget.transform.position, speed);
transform.rotation = Quaternion.Lerp(transform.rotation, camTarget.transform.rotation, speed);
} else {
// Lock cam
}
The camTarget is a game object parented to the player.
Comment