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(); 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(); } }