Files
HauntedBloodlines/Assets/Scripts/Animations Scripts/HallucinationsEyeSourceObject.cs
2025-05-29 22:31:40 +03:00

49 lines
1.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(Collider))]
public class HallucinationsEyeSourceObject : MonoBehaviour
{
private HallucinationsEye hallucinationsEye;
private void Awake()
{
// Βρίσκουμε τον γονέα HallucinationsEye
hallucinationsEye = GetComponentInParent<HallucinationsEye>();
if (hallucinationsEye == null)
{
Debug.LogError("HallucinationsEyeSourceObject: Could not find parent HallucinationsEye component.");
enabled = false;
}
}
private void Start()
{
// Set up aiming after a brief delay
StartCoroutine(SetUpMultiAimConstraintData());
}
private IEnumerator SetUpMultiAimConstraintData()
{
// Μικρή καθυστέρηση ώστε να έχει αρχικοποιηθεί το EyesManager
yield return new WaitForSeconds(0.5f);
// Αν υπάρχουν πολλαπλά MultiAimConstraints, ενημερώνουμε κάθε ένα
foreach (var constraint in hallucinationsEye.eyeMultiAimConstraints)
{
if (constraint == null) continue;
var data = constraint.data.sourceObjects;
if (data.Count > 0)
{
data.SetTransform(0, PlayerManager.GetInstance().playerHead.transform);
constraint.data.sourceObjects = data;
}
}
// Αναδημιουργούμε το rig για να εφαρμοστούν οι αλλαγές
if (hallucinationsEye.eyeRigBuilder != null)
hallucinationsEye.eyeRigBuilder.Build();
}
}