-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStageVoice.cs
More file actions
64 lines (53 loc) · 1.92 KB
/
StageVoice.cs
File metadata and controls
64 lines (53 loc) · 1.92 KB
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
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;
public class StageVoice : UdonSharpBehaviour
{
[Header("Voice Box Area")]
[Tooltip("The collider which influences voice range")]
public Collider _voiceBox;
[Header("Original Player Voice")]
[Tooltip("Existing player volume")]
[Range(0f, 24f)]
public float _originalVoiceGain = 15f;
[Tooltip("The end of the range for hearing a user's voice")]
public float _originalVoiceFar = 25f;
[Tooltip("The near radius in meters where player audio starts to fall off, it is recommended to keep this at 0")]
public float _originalVoiceNear = 0f;
[Header("Modified Player Voice")]
[Tooltip("New player volume")]
[Range(-20f, 24f)]
public float _modifiedVoiceGain = -20f;
[Tooltip("The end of the range for hearing a user's voice")]
public float _modifiedVoiceFar = 500f;
[Tooltip("The near radius in meters where player audio starts to fall off, it is recommended to keep this at 0")]
public float _modifiedVoiceNear = 250f;
public void OnPlayerTriggerEnter(VRCPlayerApi player)
{
if (!player.isLocal) {
// Player voice
player.SetVoiceGain(_modifiedVoiceGain);
player.SetVoiceDistanceFar(_modifiedVoiceFar);
player.SetVoiceDistanceNear(_modifiedVoiceNear);
}
}
public void OnPlayerTriggerStay(VRCPlayerApi player)
{
if (!player.isLocal) {
// Player voice
player.SetVoiceGain(_modifiedVoiceGain);
player.SetVoiceDistanceFar(_modifiedVoiceFar);
player.SetVoiceDistanceNear(_modifiedVoiceNear);
}
}
public void OnPlayerTriggerExit(VRCPlayerApi player)
{
if (!player.isLocal) {
// Player voice
player.SetVoiceGain(_originalVoiceGain);
player.SetVoiceDistanceFar(_originalVoiceFar);
player.SetVoiceDistanceNear(_originalVoiceNear);
}
}
}