-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGazeEnter.cs
54 lines (45 loc) · 1.39 KB
/
GazeEnter.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Button : MonoBehaviour {
public GameObject man;
public float speed = 1f;
public Vector3 rotAmount = new Vector3(0, 0, 0);
// Use this for initialization
void Start () {
man = GameObject.Find("man");
}
// Update is called once per frame
void Update () {
}
public void GazeEnterEvent()
{
//stop walking
VRAutoscript.moveforward = false;
VRAutoscript.speed = 0;
//start GameObject Rotations
StartCoroutine(Rotations());
}
IEnumerator Rotations()
{
float endTime = Time.time + speed; // When to end the coroutine
float step = 1f / speed; // How much to step by per sec
var fromAngle = transform.eulerAngles; // start rotation
var targetRot = transform.eulerAngles + rotAmount; // where we want to be at the end
float t = 0; // how far we are. 0-1
while (Time.time <= 180)
{
t += step * Time.deltaTime;
//transform.eulerAngles = Vector3.Lerp(targetRot, transform.eulerAngles, t);
man.transform.Rotate((0), (1f), (0) * t);
yield return 0;
}
yield return 180;
}
public void GazeEnterExit()
{
//Walking again
VRAutoscript.moveforward = true;
VRAutoscript.speed = 3f;
}
}