Trying to make the camera be tied to one object and watched all the time on another. I need the script to be all the time on one distance from one object and the other was exactly around the middle of the screen. Posted by such a script.
Public Class Cameramove: Monobehaviour {
Public GameObject Player;
Public GameObject Enemy;
Private vector3 offset;
Private Void Start ()
{
offset = transform.position - enemy.transform.position;
}
Private Void LateUpdate ()
{
transform.rotation = quaternion.lookrotation (enemy.transform.position - transform.position);
transform.position = player.transform.position + offset;
}
}
separately everything seems to work, but when it does not work together. How else can I realize my task
Answer 1, Authority 100%
Public Transform Target;
Void Update ()
{
// Rotate The Camera Every Frame SO IT Keeps Looking At The Target
transform.lookat (target);
}
Taken from:
https://docs.unity3d.com/scriptreference/transform.lookat.html
Cowwords for which found “Unity Camera Look AT”
Answer 2
Free plugin cinemachine is suitable for camera management. It is difficult to understand, but if you cope the camera and not such miracles will do. For simple actions, it’s like a gun on sparrows, but for something serious I am very advised.