Hey there, i would like to make the camera i am currently working with, follow the target GameObjcet smoothly.
This is the script i have at the moment.
using UnityEngine;
using System.Collections;
/*
*
* Author Christoffer "Dakk" Krook
*
* */
public class UsedCameraScript : MonoBehaviour {
public Transform target;
private float currentXAngle = 43;
private float currentYAngle = 0;
private float currentZAngle = 0;
private float currentXPos = 0f;
private float currentYPos = 0f;
private float currentZPos = 0f;
// Use this for initialization
void Start () {
currentXPos = transform.position.x;
currentYPos = transform.position.y;
currentZPos = transform.position.z;
}
// Update is called once per frame
void Update () {
currentXPos += target.transform.position.x;
currentYPos += target.transform.position.y;
currentZPos += target.transform.position.z;
//Flyttar kameran så att den sitter där den ska. Den följer skarpt i Xled men inte i Zled. Yled rörs ej.
transform.position = new Vector3(target.transform.position.x, target.transform.position.y+3.7f, target.transform.position.z/2-8.5f);
transform.eulerAngles = new Vector3(currentXAngle, currentYAngle, currentZAngle);
}
}
And it follows a GameObject sharply on the X axis and a little less sharp on the zAxis. Could someone here teach me how i could make it a little smoother on the x as well as a the z axis.