I have created smooth camera follow script which tracks player in the x axis. Now i'm trying to figure out how to make the camera look ahead of the player.
This is what i got so far:
using UnityEngine;
using System.Collections;
public class CameraFollow : MonoBehaviour {
public Transform player;
public float smoothTime = 0.3f;
private Vector3 velocity = Vector3.zero;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Vector3 targetPosition = player.transform.position;
targetPosition.z = transform.position.z;
targetPosition.y = 0f;
transform.position = Vector3.SmoothDamp (transform.position, targetPosition, ref velocity, smoothTime);
}
}
Any ideas?
↧