Hey I'm new to using Unity3d and I've tried to make my own Custom Camera but it seems to studder. Any ideas?
using UnityEngine;
using System.Collections;
public class CCamera : MonoBehaviour
{
public GameObject targetPlayer;
private float howFarForward;
private float howFarRight;
private float howFarLeft;
private float rightNowForward;
private float rightNowLeft;
public float tooFar;
public float tooRight;
public float tooLeft;
void LateUpdate()
{
transform.LookAt(targetPlayer.transform);
//howFar1 = (this.transform.position.z * -1) + targetPlayer.transform.position.z;
//howFar2 = (targetPlayer.transform.position.z) - this.transform.position.z;
howFarForward = (targetPlayer.transform.position.z * -1) - this.transform.position.z;
if (howFarForward < tooFar)
{
rightNowForward += 1f * Time.deltaTime;
}
howFarLeft = targetPlayer.transform.position.x - this.transform.position.x;
if (howFarLeft < tooLeft)
{
rightNowLeft += -5f * Time.deltaTime;
}
else if (howFarLeft > tooLeft)
{
rightNowLeft += 5f * Time.deltaTime;
}
transform.position = new Vector3(rightNowLeft, transform.position.y, rightNowForward);
transform.Rotate(0, 0, 0, Space.World);
}
}