diff options
Diffstat (limited to 'Assets/Scripts/CameraScript.cs')
-rwxr-xr-x | Assets/Scripts/CameraScript.cs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/Assets/Scripts/CameraScript.cs b/Assets/Scripts/CameraScript.cs new file mode 100755 index 0000000..93bc548 --- /dev/null +++ b/Assets/Scripts/CameraScript.cs @@ -0,0 +1,32 @@ +using UnityEngine; +using System.Collections; + +public class CameraScript : MonoBehaviour { + + GameObject Player; + Vector3 newPosition; + public float MinYOffset = 10.8f; + + void Start () + { + newPosition = new Vector3(); + Player = GameObject.FindGameObjectWithTag("Player"); + } + + + void FixedUpdate () + { + newPosition.x = Mathf.Lerp(gameObject.transform.position.x, Player.transform.position.x, .2f); + + var y = ((int)(Player.transform.position.y / 15) * 15) + MinYOffset; + if (y < MinYOffset) { y = MinYOffset; } + newPosition.y = Mathf.Lerp(gameObject.transform.position.y, (float)y, .05f); + + newPosition.z = gameObject.transform.position.z; + + gameObject.transform.position = newPosition; + + //gameObject.transform.position = new Vector3(Player.transform.position.x, gameObject.transform.position.y, gameObject.transform.position.z); + + } +} |