Quantcast
Channel: Questions in topic: "follow"
Viewing all articles
Browse latest Browse all 536

2d camera follow player by looking ahead.

$
0
0
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?

Viewing all articles
Browse latest Browse all 536

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>