Stratasys-450mc-VR/Assets/Scripts/AttachWatchToHand.cs

25 lines
834 B
C#
Raw Normal View History

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!");
}
}
}