-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfirst2third.js
More file actions
56 lines (46 loc) · 1.63 KB
/
Copy pathfirst2third.js
File metadata and controls
56 lines (46 loc) · 1.63 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
using UnityEngine;
using System.Collections;
public class CameraControl : MonoBehaviour {
public Transform myTransform;
public Transform target;
private float offsetY = 1.5f;
private float offsetZ = -6.0f;
public Vector3 maxDistance;
public Vector3 minDistance;
public Vector3 curDistance;
public bool cameraSetAt;
public float smoothingSpeed = 1.0f;
private float smoothingVelocity;
void Awake(){
target = GameObject.FindWithTag("TODO").GetComponent<Transform>();
myTransform = transform;
}
// Use this for initialization
void Start () {
cameraSetAt = true;
curDistance = new Vector3 (target.position.x, target.position.y + offsetY, target.position.z + offsetZ);
}
// Update is called once per frame
void Update () {
maxDistance = new Vector3 (target.position.x, target.position.y + offsetY, target.position.z + offsetZ);
minDistance = new Vector3 (target.position.x, target.position.y, target.position.z);
// Changes the cameras current position
if(Input.GetButtonDown("TODO")){
if(cameraSetAt){
cameraSetAt = false;
}else{
cameraSetAt = true;
}
}
}
void LateUpdate(){
if(cameraSetAt)
myTransform.position = maxDistance;
if(!cameraSetAt)
myTransform.position = minDistance;
}
void updateScale () {
// Widen the object by 0.5
myTransform.localScale += new Vector3(0.5F, 0.5F, 0.5F);
}
}