using System.Collections; using System.Collections.Generic; using System.Linq; using UnityEngine; using Variables; public class ChestController : MonoBehaviour { [SerializeField, Header("References")] private Animator m_chestAnimator; [SerializeField] private Animator m_playerAnimator; [SerializeField] private Reference m_freezePlayer; [SerializeField] private Reference m_isVictory; private void OnTriggerEnter2D(Collider2D collision) { Animator[] animators = collision.GetComponentsInChildren().Concat(collision.GetComponentsInParent()).ToArray(); if (animators.Contains(m_playerAnimator)) { m_chestAnimator.SetBool("Open", true); m_playerAnimator.SetTrigger("Victory"); m_freezePlayer.Value = true; m_isVictory.Value = true; } } }