-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMenuRotate.cs
64 lines (56 loc) · 1.72 KB
/
MenuRotate.cs
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
57
58
59
60
61
62
63
64
using UnityEngine;
using System.Collections;
public class MenuRotate : MonoBehaviour
{
private GameObject planet;
public bool rotate;
public bool lerp;
private Vector3 lerpTo = new Vector3(-10.93764f, -0.01740861f, 30.38736f);
// Use this for initialization
void Start ()
{
planet = GameObject.Find("Planet");
rotate = false;
lerp = false;
}
// Update is called once per frame
void Update ()
{
// If old menu, rotate around planet
if(rotate)
{
this.transform.RotateAround(planet.transform.position, planet.transform.up, 75 * Time.deltaTime);
if (this.transform.eulerAngles.y >= 105f && this.transform.eulerAngles.y <= 115f)
{
rotate = false;
this.transform.position = new Vector3(-10.93764f, -0.01740861f, -35.42116f);
this.transform.eulerAngles = new Vector3(0, 0, 0);
}
}
// If new menu, lerp it into view
if(lerp)
{
this.transform.position = Vector3.Lerp(this.transform.position, lerpTo, 3 * Time.deltaTime);
if (Vector3.Distance(this.transform.position, lerpTo) <= 0.1f)
{
this.transform.position = lerpTo;
lerp = false;
}
}
}
// Snap the menu into place before moving it.
public void snap(bool newObj)
{
if(newObj)
{
rotate = false;
this.transform.position = new Vector3(-10.93764f, -0.01740861f, -8.705765f);
this.transform.eulerAngles = new Vector3(0, 0, 0);
}
else
{
lerp = false;
this.transform.position = lerpTo;
}
}
}