- Home /
Minimap rotation
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 got the script from this Youtube video:
do u have any suggestions? thanks
after 'transform.position'
I am changing my first comment into an answer
Answer by jcooz · Jun 03, 2012 at 10:59 PM
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.
can u copy and paste my script and put the code in the script then post it here? it would really help.
Answer by You! · May 27, 2012 at 04:31 PM
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)
}
}
im having trouble with it. can u copy and paste the camerafollow script have add your code in the right place and then put it on here? that would be helpful
using UnityEngine
public class CameraFollow : $$anonymous$$onoBehaviour {
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)
}
}
im getting a compiler error saying that vector3 couldnt be turned into quaternion
...Sorry I couldn't get back to you... I really don't know how to help you any further... I would listen to @jcooz.
You need to use transform.eulerAngles, not transform.rotation
Your answer
Follow this Question
Related Questions
Camera rotation around player while following. 6 Answers
3D effect with new UI system 1 Answer
Rotate camera only in 2 directions based on player touch 1 Answer
Camera follow rotating ball 2 Answers
Replicate rotation of Camera 1 Answer