-
Notifications
You must be signed in to change notification settings - Fork 0
/
PlayerHeight.cs
77 lines (64 loc) · 2.22 KB
/
PlayerHeight.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
65
66
67
68
69
70
71
72
73
74
75
76
77
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Valve.VR;
using VRTK;
public class PlayerHeight : MonoBehaviour
{
// public SteamVR_Action_Boolean teleport;
// public SteamVR_Action_Boolean teleport2;
// Start is called before the first frame update
void Start()
{
//当Grip被按下时执行TrunUpRight函数
transform.Find("RightController").GetComponent<VRTK_ControllerEvents>().GripTouchStart
+= new VRTK.ControllerInteractionEventHandler(TrunUpRight);
transform.Find("RightController").GetComponent<VRTK_ControllerEvents>().GripTouchEnd
+= new VRTK.ControllerInteractionEventHandler(TrunDownRight);
transform.Find("LeftController").GetComponent<VRTK_ControllerEvents>().GripTouchStart
+= new VRTK.ControllerInteractionEventHandler(TrunUpLeft);
transform.Find("LeftController").GetComponent<VRTK_ControllerEvents>().GripTouchEnd
+= new VRTK.ControllerInteractionEventHandler(TrunDownLeft);
transform.Find("RightController").GetComponent<VRTK_ControllerEvents>().TriggerTouchStart
+= new VRTK.ControllerInteractionEventHandler(NextStep);
}
public GameManager2 GameManager2;
void NextStep(object sender, VRTK.ControllerInteractionEventArgs e)
{
GameManager2.Click();
}
void TrunUpRight(object sender, VRTK.ControllerInteractionEventArgs e)
{
Debug.Log(111);
RightHit = true;
}
void TrunDownRight(object sender, VRTK.ControllerInteractionEventArgs e)
{
Debug.Log(111);
RightHit = false;
}
void TrunUpLeft(object sender, VRTK.ControllerInteractionEventArgs e)
{
Debug.Log(111);
LeftHit = true;
}
void TrunDownLeft(object sender, VRTK.ControllerInteractionEventArgs e)
{
Debug.Log(111);
LeftHit = false;
}
private bool LeftHit = false;
private bool RightHit = false;
public Transform Playe;
void Update()
{
if (RightHit)
{
Playe.transform.position += new Vector3(0, 0.02f, 0);
}
if (LeftHit)
{
Playe.transform.position -= new Vector3(0, 0.02f, 0);
}
}
}