Hello,
I got a Problem with the Rotation of my Camera (Minimap) which is following me arround.
I created a second Camera, used a Script which makes the Camera follow me and then I changed the Viewport Rect so its in the Corner. My Problem now is, that the Camera´s Rotation is not correct.
As you can see I made 2 arrows, what i want is that both arrows show in the same Direction.
This is the Script which is attached to the Map-Camera:
// The target we are following
var target : Transform;
// The distance in the x-z plane to the target
var distance = 10.0;
// the height we want the camera to be above the target
var height = 5.0;
// How much we
var heightDamping = 2.0;
var rotationDamping = 3.0;
// Place the script in the Camera-Control group in the component menu
@script AddComponentMenu("Camera-Control/Smooth Follow")
function LateUpdate () {
// Early out if we don't have a target
if (!target)
return;
// Calculate the current rotation angles
var wantedRotationAngle = target.eulerAngles.y;
var wantedHeight = target.position.y + height;
var currentRotationAngle = transform.eulerAngles.y;
var currentHeight = transform.position.y;
// Damp the rotation around the y-axis
currentRotationAngle = (Mathf.LerpAngle (currentRotationAngle, wantedRotationAngle, rotationDamping * Time.deltaTime));
// Damp the height
currentHeight = Mathf.Lerp (currentHeight, wantedHeight, heightDamping * Time.deltaTime);
// Convert the angle into a rotation
var currentRotation = Quaternion.Euler (0, currentRotationAngle, 0);
// Set the position of the camera on the x-z plane to:
// distance meters behind the target
transform.position = target.position;
transform.position -= currentRotation * Vector3.forward * distance;
// Set the height of the camera
transform.position.y = currentHeight;
// Always look at the target
transform.LookAt (target);
}
And these are my Values:
The Script is not from me, i just found it in the Internet and everything worked just not the Rotation thing.
I tried around just adding a “-90” somewhere so the Rotation is changed but i dont understand where and what i have to change.
I appreciate every help