blob: 93bc548da5494156d2477129034e484e7acc50cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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);
}
}
|