-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
TagArrayTP.cs
39 lines (37 loc) · 1.39 KB
/
TagArrayTP.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
using UnityEngine;
using VRC.SDKBase;
using UdonSharp;
namespace UwUtils
{
[AddComponentMenu("UwUtils/TagArrayTP")]
[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
public class TagArrayTP : UdonSharpBehaviour
{
[Header("Tag name array (Tag 1 TPs to Target 1, 2 to 2...)")]
[SerializeField] private string[] tagAllowed;
[Header("TP Targets (Target1 for Tag1, T2 to T2...)")]
[SerializeField] private Transform[] targetLocation;
[Header("TP to fallback location when no matching tag ?")]
[SerializeField] private bool tpFallbackEnabled;
[Header("Fallback Location")]
[SerializeField] private Transform targetFallback;
public override void Interact()
{
if (Networking.LocalPlayer != null && Networking.LocalPlayer.GetPlayerTag("rank") != null)
{
for (var i = 0; i < tagAllowed.Length; i++)
{
if (tagAllowed[i] != Networking.LocalPlayer.GetPlayerTag("rank")) continue;
Networking.LocalPlayer.TeleportTo(targetLocation[i].position, targetLocation[i].rotation);
}
}
else
{
if (tpFallbackEnabled)
{
Networking.LocalPlayer.TeleportTo(targetFallback.position, targetFallback.rotation);
}
}
}
}
}