I have downloaded from internet this camera script for smooth follow
using UnityEngine;
using System.Collections;
public class FollowCamera : MonoBehaviour {
public GameObject target;
public float damping = 1;
Vector3 offset;
void Start() {
offset = target.transform.position - transform.position;
}
void LateUpdate() {
float currentAngle = transform.eulerAngles.y;
float desiredAngle = target.transform.eulerAngles.y;
float angle = Mathf.LerpAngle(currentAngle, desiredAngle, Time.deltaTime * damping);
Quaternion rotation = Quaternion.Euler(0, angle, 0);
transform.position = target.transform.position - (rotation * offset);
transform.LookAt(target.transform);
}
}
The problem is that it sets the camera to a position related to the player like this in the image
I wanted the camera to have a rotation like this, being more “horizontally”
I have no idea how to change that, can someone help me??
(The camera is in the scene in position B, but when I start the game, it goes to the position A)
image : http://imageshack.us/photo/my-images/202/39794077.png/
In the Start() method, the script creates an ‘offset’ parameter based on where the camera is placed relative to the target. You need to adjust the start position of the camera to be where you want it relative to the target. When the script starts, it will ‘lock’ to that offset.
You need to change the offset which is going to be the distance from the target. Modify desiredAngle initialization to change the viewing angle.
What you can do is add a simple object (that you wont render) as a child to your player (or cube in this case) and add that child to this camera script as a target.