OLD_STEP_LIST_EDITOR
Documentation for the Unity C# Library
Loading...
Searching...
No Matches
NearWaypoint.cs
Go to the documentation of this file.
1
using
PixoVR.Core
;
2
using
UnityEngine;
3
4
namespace
PixoVR.Event
5
{
6
public
class
WaypointRespawnEvent
7
{
8
public
Transform
RespawnTransform
{
get
;
set
; }
9
}
10
11
public
class
NearWaypoint
: MonoBehaviour
12
{
13
[SerializeField]
private
GameObject[]
waypoints
;
14
private
Transform
_cameraTransform
;
15
16
private
void
Awake
()
17
{
18
_cameraTransform
= Camera.main.transform;
19
}
20
21
private
void
OnEnable
()
22
{
23
// CheckNearestPoint();
24
}
25
26
public
void
CheckNearestPoint
()
27
{
28
float
min = 9999;
29
int
index = 0;
30
for
(
int
i = 0; i <
waypoints
.Length; i++)
31
{
32
if
(Vector3.Distance(
_cameraTransform
.position,
waypoints
[i].transform.position) < min
33
&&
waypoints
[i].activeSelf)
34
{
35
index = i;
36
min = Vector3.Distance(
_cameraTransform
.position,
waypoints
[i].transform.position);
37
}
38
}
39
RespawntoWaypoint
(index);
40
}
41
42
private
void
RespawntoWaypoint
(
int
index)
43
{
44
transform.SetPositionAndRotation(
waypoints
[index].transform.position,
45
waypoints
[index].transform.rotation);
46
47
EventBetter
.Raise(
new
WaypointRespawnEvent
()
48
{
49
RespawnTransform = transform
50
});
51
}
52
}
53
}
PixoVR.Core.EventBetter
Intentionally made partial, in case you want to extend it easily.
Definition
EventBetter.cs:20
PixoVR.Event.NearWaypoint
Definition
NearWaypoint.cs:12
PixoVR.Event.NearWaypoint.waypoints
GameObject[] waypoints
[SerializeField]
Definition
NearWaypoint.cs:16
PixoVR.Event.NearWaypoint.RespawntoWaypoint
void RespawntoWaypoint(int index)
Definition
NearWaypoint.cs:45
PixoVR.Event.NearWaypoint.Awake
void Awake()
Definition
NearWaypoint.cs:19
PixoVR.Event.NearWaypoint.OnEnable
void OnEnable()
Definition
NearWaypoint.cs:24
PixoVR.Event.NearWaypoint.CheckNearestPoint
void CheckNearestPoint()
Definition
NearWaypoint.cs:29
PixoVR.Event.NearWaypoint._cameraTransform
Transform _cameraTransform
Definition
NearWaypoint.cs:17
PixoVR.Event.WaypointRespawnEvent
Definition
NearWaypoint.cs:7
PixoVR.Event.WaypointRespawnEvent.RespawnTransform
Transform RespawnTransform
Definition
NearWaypoint.cs:8
PixoVR.Core
Definition
EventBetter.cs:14
PixoVR.Event
Definition
ItemIDAttribute.cs:5
com.pixovr.eventunitysdk
Runtime
Sdk
Scripts
NearWaypoint.cs
Generated
Wed Oct 9 2024 19:24:03
by Doxygen version
1.10.0