Camera Positioning When Following Character
Hey everyone! I am new to C# and am working on making some 2D games to start to get the hang of it. I have a script that works really well for camera movement, but when I enter game play, the overall composition looks off. I would like to lower the default position of the camera so I can see more of the forgeound.
using UnityEngine; using System.Collections; public class SmoothCamera2D : 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 = GetComponent<Camera>().WorldToViewportPoint(target.position); Vector3 delta = target.position - GetComponent<Camera>().ViewportToWorldPoint(new Vector3(0.5f, 0.5f, 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); } } }
I added a screenshot of the game view to show you what I mean.
Thank you!