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:
- Name:
Entry: 12
Data: 5
Data: 4
- Name:
Entry: 7
Data:
@ -267,60 +267,6 @@ MonoBehaviour:
- Name:
Entry: 8
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:
Entry: 13
Data:

View File

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