diff options
author | nirav <nirav@airmail.cc> | 2020-12-12 07:18:36 +0000 |
---|---|---|
committer | nirav <nirav@airmail.cc> | 2020-12-12 07:18:36 +0000 |
commit | 115f77bda0246a00f6e17469685c67746bdbd29d (patch) | |
tree | 4bbea1e59109bb1d1fddc71736f89289bab03073 /Assets/Scripts/CameraScript.cs | |
download | 01-115f77bda0246a00f6e17469685c67746bdbd29d.tar.gz 01-115f77bda0246a00f6e17469685c67746bdbd29d.zip |
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); + + } +} |