/// ---------------------------------------------
/// Ultimate Character Controller
/// Copyright (c) Opsive. All Rights Reserved.
/// https://www.opsive.com
/// ---------------------------------------------
namespace Opsive.UltimateCharacterController.Demo
{
using Opsive.UltimateCharacterController.Game;
using Opsive.UltimateCharacterController.Objects.CharacterAssist;
using Opsive.UltimateCharacterController.Utility;
using UnityEngine;
///
/// Resets the specified interactable objects when the character leaves the room.
///
public class InteractRoomReset : MonoBehaviour
{
[Tooltip("A list of objects that should be reset when the character leaves the room.")]
public GameObject[] m_InteractObjects;
///
/// An object has exited the trigger.
///
/// The collider that exited the trigger.
private void OnTriggerExit(Collider other)
{
// A main character collider is required.
if (!MathUtility.InLayerMask(other.gameObject.layer, 1 << LayerManager.Character)) {
return;
}
ResetInteractObjects();
}
///
/// Resets the interact room objects.
///
private void ResetInteractObjects()
{
for (int i = 0; i < m_InteractObjects.Length; ++i) {
var animatedInteractables = m_InteractObjects[i].GetComponents();
for (int j = 0; j < animatedInteractables.Length; ++j) {
animatedInteractables[j].ResetInteract();
}
}
}
}
}