Quantcast
Channel: Questions in topic: "ios"
Viewing all articles
Browse latest Browse all 4709

How to stop the camera moving up and down with the player when following them?

$
0
0
I would like to get my camera to follow the player like in this video: https://www.youtube.com/watch?v=6ZjHXcAI4RA, and not 'drop' as the player drops, and go up when the player goes up, like it does in this script: public class camerafollow : MonoBehaviour { public float dampTime = 0.15f; private Vector3 velocity = Vector3.zero; public Transform target; // Update is called once per frame void Update () { if (target) { Vector3 point = transform.GetComponent().WorldToViewportPoint(target.position); Vector3 delta = target.position - transform.GetComponent().ViewportToWorldPoint(new Vector3(point.x, 0.7f, point.z)); //(new Vector3(0.5, 0.5, point.z)); Vector3 destination = transform.position + delta; transform.position = Vector3.SmoothDamp(transform.position, destination, ref velocity, dampTime); } Anyone know how? Thanks

Viewing all articles
Browse latest Browse all 4709

Trending Articles



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