/// --------------------------------------------- /// Ultimate Character Controller /// Copyright (c) Opsive. All Rights Reserved. /// https://www.opsive.com /// --------------------------------------------- namespace Opsive.UltimateCharacterController.Character { using Opsive.UltimateCharacterController.Utility; using UnityEngine; /// /// Notifies the CharacterFootEffects component when the foot has collided with the ground. /// public class FootstepTrigger : MonoBehaviour { [Tooltip("Should the footprint texture be flipped?")] [SerializeField] protected bool m_FlipFootprint; public bool FlipFootprint { get { return m_FlipFootprint; } set { m_FlipFootprint = value; } } private Transform m_Transform; private CharacterFootEffects m_FootEffects; private CharacterLayerManager m_CharacterLayerManager; /// /// Initialize the default values. /// private void Awake() { m_Transform = transform; m_FootEffects = GetComponentInParent(); m_CharacterLayerManager = GetComponentInParent(); } /// /// The trigger has collided with another object. /// /// The Collider that the trigger collided with. private void OnTriggerEnter(Collider other) { // Notify the CharacterFootEffects component if the layer is valid. if (MathUtility.InLayerMask(other.gameObject.layer, m_CharacterLayerManager.IgnoreInvisibleCharacterWaterLayers)) { m_FootEffects.FootStep(m_Transform, m_FlipFootprint); } } } }