-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTeleportObject.cs
executable file
·80 lines (64 loc) · 2.77 KB
/
TeleportObject.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
78
79
80
using UnityEngine;
using VRTK;
/*
Author: Evan Otero
Date: Feb 10, 2017
TeleportObject is an object in the scene that can be "used", which will result in the player being
teleported to a specified scene (given in the field in the editor). Overriding the default use button,
which is the trigger, improves the process. This is due to the fact that some scenes are loading quickly,
which then causes the user to be immediatly teleported to the scene since the trigger hasn't had time to be
unreleased.
TeleportObject inherits from VRTK_InteractableObject.
***********************
******* LICENSE *******
***********************
JoyceStick is a Boston College digital humanities project employing Unity
to construct a virtual reality game from Joyce’s Ulysses for viewing on the
HTC Vive, supported by a Teaching and Mentoring Grant and substantial funding
from internal bodies at Boston College.
Copyright (C) 2017 Evan Otero, Drew Hoo, Emaad Ali, Will Bowditch, Matt Harty, Jake Schafer, & Ryan Reede
http://joycestick.bc.edu/
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
public class TeleportObject : VRTK_InteractableObject
{
[SerializeField]
private string nextSceneName;
[SerializeField]
private bool onUse;
[SerializeField]
private GameObject tooltipsObject;
private VRTK_ControllerTooltips tooltips;
protected void Start()
{
this.tooltips = tooltipObject.GetComponent<VRTK_ControllerTooltips>();
}
protected override void Update()
{
base.Update();
}
public override void Grabbed(GameObject usingObject)
{
tooltips.triggerText = "Enter " + nextSceneName;
base.Grabbed(usingObject);
if (!onUse)
StartCoroutine(SceneLoader.instance.AsyncLoadScene(nextSceneName));
}
public override void StartUsing(GameObject usingObject)
{
base.StartUsing(usingObject);
if (onUse)
StartCoroutine(SceneLoader.instance.AsyncLoadScene(nextSceneName));
}
public override void Ungrabbed(GameObject usingObject) { }
public override void StopUsing(GameObject usingObject) { }
}