summaryrefslogtreecommitdiff
path: root/SurvivalTest/Assets/ACS-17/Demo_Table_Animations/Scripts/CharacterViewer.cs
diff options
context:
space:
mode:
Diffstat (limited to 'SurvivalTest/Assets/ACS-17/Demo_Table_Animations/Scripts/CharacterViewer.cs')
-rw-r--r--SurvivalTest/Assets/ACS-17/Demo_Table_Animations/Scripts/CharacterViewer.cs54
1 files changed, 54 insertions, 0 deletions
diff --git a/SurvivalTest/Assets/ACS-17/Demo_Table_Animations/Scripts/CharacterViewer.cs b/SurvivalTest/Assets/ACS-17/Demo_Table_Animations/Scripts/CharacterViewer.cs
new file mode 100644
index 0000000..960734a
--- /dev/null
+++ b/SurvivalTest/Assets/ACS-17/Demo_Table_Animations/Scripts/CharacterViewer.cs
@@ -0,0 +1,54 @@
+using UnityEngine;
+using System.Collections;
+using UnityEngine.UI;
+
+public class CharacterViewer : MonoBehaviour {
+ //Script control of the camera in the table animation
+ public Transform cameras;
+
+ public Transform targetForCamera;
+ Vector3 deltaPosition;
+ Vector3 lastPosition = Vector3.zero;
+ bool rotating = false;
+
+ void Awake () {
+ deltaPosition = cameras.position - targetForCamera.position;
+ deltaPosition = new Vector3(deltaPosition.x, deltaPosition.y - (-0.1f) * 5, deltaPosition.z +(-0.1f) * 8);
+ transform.Rotate(0, -300f * -170 / Screen.width, 0);
+ }
+
+ void Update () {
+ if (Input.GetMouseButtonDown (0) && Input.mousePosition.x > Screen.width*0.25 ) {
+ lastPosition = Input.mousePosition;
+ rotating = true;
+ }
+
+ if (Input.GetMouseButtonUp(0))
+ rotating = false;
+
+ if (rotating && Input.GetMouseButton(0))
+ {
+ transform.Rotate(0, -300f * (Input.mousePosition - lastPosition).x / Screen.width, 0);
+
+ }
+
+ if (Input.GetAxis("Mouse ScrollWheel")!=0)
+ {
+
+ var y = 0f;
+ if (Input.GetAxis("Mouse ScrollWheel") < 0 && deltaPosition.y < 18) y = Input.GetAxis("Mouse ScrollWheel");
+ if (Input.GetAxis("Mouse ScrollWheel") > 0 && deltaPosition.y > 10f) y = Input.GetAxis("Mouse ScrollWheel");
+ deltaPosition = new Vector3(deltaPosition.x, deltaPosition.y - y * 5, deltaPosition.z + y * 8);
+ }
+
+
+ lastPosition = Input.mousePosition;
+ }
+
+ void LateUpdate () {
+ cameras.position += (targetForCamera.position + deltaPosition - cameras.position) * Time.unscaledDeltaTime * 5;
+ Vector3 relativePos = targetForCamera.position - cameras.position;
+ Quaternion rotation = Quaternion.LookRotation(relativePos);
+ cameras.rotation = rotation;
+ }
+}