Fixed watch left wrist orientation

fixed the watch orientation on the left hand so it faces the right way
This commit is contained in:
Cody Wright 2024-02-01 15:51:35 -05:00
parent 3f5c7ab5e9
commit 2e28950d97
2 changed files with 17 additions and 22 deletions

View File

@ -48,8 +48,8 @@ MonoBehaviour:
m_EditorClassIdentifier:
handTransform: {fileID: 0}
watchOffsetPosition: {x: 0, y: 0, z: 0}
watchRightOffsetRotation: {x: 0, y: 0, z: -90}
watchLeftOffsetRotation: {x: 0, y: 0, z: 90}
watchRightOffsetRotation: {x: 0, y: -90, z: -90}
watchLeftOffsetRotation: {x: 0, y: 90, z: -90}
leftHand: {fileID: 0}
rightHand: {fileID: 0}
--- !u!114 &1125641476039870382

View File

@ -4,8 +4,8 @@ public class AttachWatchToHand : MonoBehaviour
{
public Transform handTransform; // Assign the hand's transform
public Vector3 watchOffsetPosition; // Offset from the hand for watch positioning
public Vector3 watchRightOffsetRotation = new Vector3(0, 0, -90);
public Vector3 watchLeftOffsetRotation = new Vector3(0, 0, 90);
public Vector3 watchRightOffsetRotation = new Vector3(0, -90, -90);
public Vector3 watchLeftOffsetRotation = new Vector3(0, 90, -90);
public Transform leftHand;
@ -13,26 +13,21 @@ public class AttachWatchToHand : MonoBehaviour
void Update()
{
if (handTransform != null && handTransform == rightHand)
if (handTransform == null)
{
Quaternion rotation = Quaternion.Euler(handTransform.rotation.eulerAngles + watchRightOffsetRotation);
return;
}
Quaternion rotation = Quaternion.Euler(handTransform.rotation.eulerAngles);
// Update the watch position and rotation to follow the hand
transform.position = handTransform.position + handTransform.TransformDirection(watchOffsetPosition);
transform.rotation = rotation;
}
else if (handTransform != null && handTransform == leftHand)
{
Quaternion leftRotation = Quaternion.Euler(handTransform.rotation.eulerAngles + watchLeftOffsetRotation);
// Update the watch position and rotation to follow the hand
transform.position = handTransform.position + handTransform.TransformDirection(watchOffsetPosition);
transform.rotation = leftRotation;
}
else
transform.GetChild(0).localRotation = Quaternion.Euler(watchRightOffsetRotation);
if (handTransform == leftHand)
{
Debug.LogWarning("Hand transform not assigned!");
transform.GetChild(0).localRotation = Quaternion.Euler(watchLeftOffsetRotation);
}
}