Stratasys-450mc-VR/Assets/Scripts/AttachWatchToHand.cs
Cody Wright b4656bf24a Fixed watch texture
added the missing watch texture and corrected the watch orientation
2024-01-09 15:38:27 -05:00

25 lines
834 B
C#

using UnityEngine;
public class AttachWatchToHand : MonoBehaviour
{
public Transform handTransform; // Assign the hand's transform
public Vector3 watchOffsetPosition; // Offset from the hand for watch positioning
public Vector3 watchOffsetRotation = new Vector3(0, 0, -90);
void Update()
{
if (handTransform != null)
{
Quaternion rotation = Quaternion.Euler(handTransform.rotation.eulerAngles + watchOffsetRotation);
// Update the watch position and rotation to follow the hand
transform.position = handTransform.position + handTransform.TransformDirection(watchOffsetPosition);
transform.rotation = rotation;
}
else
{
Debug.LogWarning("Hand transform not assigned!");
}
}
}