2 using System.Collections;
16 private Transform mainCamera;
18 public float boomStep = 2f;
20 private const float boomMin = 2f;
21 private const float boomMax = 1000f;
26 mainCamera = transform.GetChild(0);
31 float boomLength = mainCamera.localPosition.z;
33 if (Input.GetKey(KeyCode.RightArrow)) {
34 transform.rotation *= Quaternion.AngleAxis( spinRate, Vector3.up);
35 }
else if (Input.GetKey(KeyCode.LeftArrow)) {
36 transform.rotation *= Quaternion.AngleAxis( -spinRate, Vector3.up);
37 }
else if (Input.GetKey(KeyCode.UpArrow)) {
38 transform.rotation *= Quaternion.AngleAxis( spinRate, Vector3.right);
39 }
else if (Input.GetKey(KeyCode.DownArrow)) {
40 transform.rotation *= Quaternion.AngleAxis( -spinRate, Vector3.right);
41 }
else if (Input.GetKey(KeyCode.Equals)) {
43 boomLength -= boomStep;
44 boomLength = Mathf.Max(boomLength, boomMin);
45 Vector3 localP = mainCamera.localPosition;
46 localP.z = boomLength;
47 mainCamera.localPosition = localP;
49 }
else if (Input.GetKey(KeyCode.Minus)) {
51 boomLength += boomStep;
52 boomLength = Mathf.Min(boomLength, boomMax);
53 Vector3 localP = mainCamera.localPosition;
54 localP.z = boomLength;
55 mainCamera.localPosition = localP;
Key control to rotate camera boom using Arrow keys. Scale with +/-.
float spinRate
Rate of spin (degrees per Update)