hey guys. i made a minimap in my scene. i want it to rotate when my character (which is in 3rd person) turns. i have this script that makes the minimap camera follow the character:
using UnityEngine;
public class CameraFollow : MonoBehaviour {
public Transform Target;
void LateUpdate()
{
transform.position = new Vector3(Target.position.x, transform.position.y, Target.position.z);
}
I followed this tutorial as well and was looking for a way to rotate the camera. After some research on EulesAngles, I found the following line to solve this problem:
transform.eulerAngles.y = Target.eulerAngles.y;
With the minimap camera facing down towards the terrain, this will set the camera to the exact angle as the character camera.
transform.rotation = new Vector3(0,Target.rotation.y,0)
after ‘transform.position’
This would lead the code to looking like this:
using UnityEngine
public class CameraFollow : MonoBehaviour {
public Transform Target;
void LateUpdate()
{
transform.position = new Vector3(Target.position.x,transform.position.y,Target.position.z)
transform.rotation = new Vector3(0,Target.rotation,y,0)
}
}