View tablet now follows head rotation also, which avoids some annoying quirks.

This commit is contained in:
Jamie Greunbaum 2026-05-24 12:48:12 -04:00
parent a7c53dbf05
commit 89caac10f0
2 changed files with 15 additions and 69 deletions

View File

@ -44,7 +44,7 @@ MonoBehaviour:
Data: Data:
- Name: - Name:
Entry: 12 Entry: 12
Data: 5 Data: 4
- Name: - Name:
Entry: 7 Entry: 7
Data: Data:
@ -267,60 +267,6 @@ MonoBehaviour:
- Name: - Name:
Entry: 8 Entry: 8
Data: Data:
- Name:
Entry: 7
Data:
- Name: $k
Entry: 1
Data: _PreviousHeadYRotation
- Name: $v
Entry: 7
Data: 15|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: _PreviousHeadYRotation
- Name: <UserType>k__BackingField
Entry: 7
Data: 16|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Single, mscorlib
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 16
- 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: 17|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: - Name:
Entry: 13 Entry: 13
Data: Data:

View File

@ -12,37 +12,37 @@ public class ViewTabletSpawner : UdonSharpBehaviour
[SerializeField] private Transform _ViewTablet; [SerializeField] private Transform _ViewTablet;
private bool _FollowPlayerHead = false; private bool _FollowPlayerHead = false;
private float _PreviousHeadYRotation = 0.0f;
void Update() void Update()
{ {
VRCPlayerApi LocalPlayer = Networking.LocalPlayer; VRCPlayerApi LocalPlayer = Networking.LocalPlayer;
_PreviousHeadYRotation = LocalPlayer.GetBoneRotation(HumanBodyBones.Head).eulerAngles.y;
if (_FollowPlayerHead) if (_FollowPlayerHead)
{ {
_ViewTabletHeadRoot.position = LocalPlayer.GetBonePosition(HumanBodyBones.Head); _ViewTabletHeadRoot.position = LocalPlayer.GetBonePosition(HumanBodyBones.Head);
_ViewTabletHeadRoot.rotation = LocalPlayer.GetBoneRotation(HumanBodyBones.Head);
} }
else else
{ {
_ViewTabletHeadRoot.localPosition = Vector3.zero; _ViewTabletHeadRoot.localPosition = Vector3.zero;
_ViewTabletHeadRoot.localRotation = Quaternion.identity;
} }
} }
public override void OnPlayerRespawn(VRCPlayerApi Player) //public override void OnPlayerRespawn(VRCPlayerApi Player)
{ //{
if (Player.isLocal) // if (Player.isLocal)
{ // {
Vector3 HeadRotation = Networking.LocalPlayer.GetBoneRotation(HumanBodyBones.Head).eulerAngles; // Vector3 HeadRotation = Networking.LocalPlayer.GetBoneRotation(HumanBodyBones.Head).eulerAngles;
HeadRotation.x = HeadRotation.z = 0.0f; // HeadRotation.x = HeadRotation.z = 0.0f;
float DeltaY = HeadRotation.y - _PreviousHeadYRotation; // float DeltaY = HeadRotation.y - _PreviousHeadYRotation;
HeadRotation.y = _ViewTabletHeadRoot.eulerAngles.y + DeltaY; // HeadRotation.y = _ViewTabletHeadRoot.eulerAngles.y + DeltaY;
_ViewTabletHeadRoot.rotation = Quaternion.Euler(HeadRotation); // _ViewTabletHeadRoot.rotation = Quaternion.Euler(HeadRotation);
} // }
base.OnPlayerRespawn(Player); // base.OnPlayerRespawn(Player);
} //}
public void SpawnAtLocalPlayerHead() public void SpawnAtLocalPlayerHead()