- LocationBoard callbacks now only run on the host.

- CameraAnchor now properly syncs followed player data.
This commit is contained in:
2026-04-21 16:35:19 -04:00
parent 47eb6aae77
commit a6b3b840b2
16 changed files with 333 additions and 264 deletions
+117 -111
View File
@@ -564,22 +564,130 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: _AttachedCamera
Data: _FollowedPlayerNames
- Name: $v
Entry: 7
Data: 37|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _AttachedCamera
Data: _FollowedPlayerNames
- Name: <UserType>k__BackingField
Entry: 7
Data: 38|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.String[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 38
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 3
Data: 1
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 39|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 1
- Name:
Entry: 7
Data: 40|UdonSharp.UdonSyncedAttribute, UdonSharp.Runtime
- Name:
Entry: 8
Data:
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _AttachedCamera
- Name: $v
Entry: 7
Data: 41|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _AttachedCamera
- Name: <UserType>k__BackingField
Entry: 7
Data: 42|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: UnityEngine.Camera, UnityEngine.CoreModule
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 42
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 43|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _FollowedPlayerNames_Cache
- Name: $v
Entry: 7
Data: 44|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _FollowedPlayerNames_Cache
- Name: <UserType>k__BackingField
Entry: 9
Data: 38
- Name: <SystemType>k__BackingField
Entry: 9
Data: 38
@@ -597,109 +705,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 39|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _FollowedPlayerNames
- Name: $v
Entry: 7
Data: 40|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _FollowedPlayerNames
- Name: <UserType>k__BackingField
Entry: 7
Data: 41|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.String[], mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 41
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 42|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
- Name:
Entry: 13
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 8
Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _FollowedPlayerNames_Cache
- Name: $v
Entry: 7
Data: 43|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _FollowedPlayerNames_Cache
- Name: <UserType>k__BackingField
Entry: 9
Data: 41
- Name: <SystemType>k__BackingField
Entry: 9
Data: 41
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
- Name:
Entry: 6
Data:
- Name:
Entry: 8
Data:
- Name: <IsSerialized>k__BackingField
Entry: 5
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 44|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 45|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -723,13 +729,13 @@ MonoBehaviour:
Data: _FollowedPlayers
- Name: $v
Entry: 7
Data: 45|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 46|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _FollowedPlayers
- Name: <UserType>k__BackingField
Entry: 7
Data: 46|System.RuntimeType, mscorlib
Data: 47|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: VRC.SDKBase.VRCPlayerApi[], VRCSDKBase
@@ -738,7 +744,7 @@ MonoBehaviour:
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 46
Data: 47
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
@@ -753,7 +759,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 47|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 48|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
@@ -777,7 +783,7 @@ MonoBehaviour:
Data: _CameraFollowSpeed
- Name: $v
Entry: 7
Data: 48|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
Data: 49|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _CameraFollowSpeed
@@ -801,7 +807,7 @@ MonoBehaviour:
Data: false
- Name: _fieldAttributes
Entry: 7
Data: 49|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
Data: 50|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
- Name:
Entry: 12
Data: 0
+35 -10
View File
@@ -1,6 +1,7 @@
using CameraSystem;
using MMMaellon.LightSync;
using System.Linq;
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
@@ -36,8 +37,9 @@ public class CameraAnchor : UdonSharpBehaviour
[UdonSynced] private int _AttachedCameraIndex = -1;
[UdonSynced] private string[] _FollowedPlayerNames = new string[0];
private Camera _AttachedCamera = null;
private string[] _FollowedPlayerNames = new string[0];
private string[] _FollowedPlayerNames_Cache = new string[0];
private VRCPlayerApi[] _FollowedPlayers = new VRCPlayerApi[0];
private float _CameraFollowSpeed = 1.0f;
@@ -65,6 +67,11 @@ public class CameraAnchor : UdonSharpBehaviour
Vector3 CentroidSum = Vector3.zero;
for (int i = 0; i < _FollowedPlayers.Length; i++)
{
if (_FollowedPlayers[i] == null)
{
continue;
}
Vector3[] BonePositions = _BonesFromFollowMethod(_FollowedPlayers[i]);
Vector3 CentroidPointsAverage = Vector3.zero;
for (int j = 0; j < BonePositions.Length; j++)
@@ -92,7 +99,6 @@ public class CameraAnchor : UdonSharpBehaviour
private Vector3[] _BonesFromFollowMethod(VRCPlayerApi Player)
{
switch(FollowMethod)
{
case PossibleFollowMethods.CloseUp:
@@ -124,10 +130,10 @@ public class CameraAnchor : UdonSharpBehaviour
case PossibleFollowMethods.HipsDown:
{
Vector3[] BonesToTrack = new Vector3[4];
BonesToTrack[2] = Player.GetBonePosition(HumanBodyBones.LeftUpperLeg);
BonesToTrack[3] = Player.GetBonePosition(HumanBodyBones.RightUpperLeg);
BonesToTrack[0] = Player.GetBonePosition(HumanBodyBones.LeftFoot);
BonesToTrack[1] = Player.GetBonePosition(HumanBodyBones.RightFoot);
BonesToTrack[0] = Player.GetBonePosition(HumanBodyBones.LeftUpperLeg);
BonesToTrack[1] = Player.GetBonePosition(HumanBodyBones.RightUpperLeg);
BonesToTrack[2] = Player.GetBonePosition(HumanBodyBones.LeftFoot);
BonesToTrack[3] = Player.GetBonePosition(HumanBodyBones.RightFoot);
return BonesToTrack;
}
case PossibleFollowMethods.FullBody:
@@ -234,21 +240,40 @@ public class CameraAnchor : UdonSharpBehaviour
VRCPlayerApi[] AllPlayers = new VRCPlayerApi[VRCPlayerApi.GetPlayerCount()];
VRCPlayerApi.GetPlayers(AllPlayers);
int i = 0;
foreach (string PlayerName in _FollowedPlayerNames)
int NumValidPlayers = 0;
for (int i = 0; i < _FollowedPlayerNames.Length; i++)
{
string PlayerName = _FollowedPlayerNames[i];
Debug.Log("[CameraAnchor] Trying to find player " + PlayerName + "...");
_FollowedPlayers[i] = null;
foreach (VRCPlayerApi Player in AllPlayers)
{
if (Player.displayName == PlayerName)
{
Debug.Log("[CameraAnchor] Found player " + PlayerName);
_FollowedPlayers[i] = Player;
i++;
NumValidPlayers++;
break;
}
}
}
Debug.Log("[CameraAnchor] Anchor " + gameObject.name + " is now following " + _FollowedPlayerNames);
Debug.Log("[CameraAnchor] Found " + NumValidPlayers + " players out of a requested " + _FollowedPlayerNames.Length);
int ValidPlayerCounter = 0;
VRCPlayerApi[] ValidPlayers = new VRCPlayerApi[NumValidPlayers];
foreach (VRCPlayerApi Player in _FollowedPlayers)
{
if (Player != null)
{
ValidPlayers[ValidPlayerCounter] = Player;
ValidPlayerCounter++;
}
}
string PlayerNamesString = string.Join(", ", _FollowedPlayerNames);
Debug.Log("[CameraAnchor] Anchor " + gameObject.name + " is now following { " + PlayerNamesString + " }");
_FollowedPlayerNames_Cache = _FollowedPlayerNames;
}