From 63795c45af9ecca5aea36fbe291b18fcd9fb9b7d Mon Sep 17 00:00:00 2001 From: chai Date: Fri, 18 Feb 2022 14:38:20 +0800 Subject: *rename folder name --- .../FPSControllerVelocity/Scripts/GroundChecker.cs | 48 ++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 JamHelper/Assets/JamUtils/FPSControllerVelocity/Scripts/GroundChecker.cs (limited to 'JamHelper/Assets/JamUtils/FPSControllerVelocity/Scripts/GroundChecker.cs') diff --git a/JamHelper/Assets/JamUtils/FPSControllerVelocity/Scripts/GroundChecker.cs b/JamHelper/Assets/JamUtils/FPSControllerVelocity/Scripts/GroundChecker.cs new file mode 100644 index 0000000..a0bd4eb --- /dev/null +++ b/JamHelper/Assets/JamUtils/FPSControllerVelocity/Scripts/GroundChecker.cs @@ -0,0 +1,48 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace JamTools +{ + + public class GroundChecker : MonoBehaviour + { + [SerializeField] private Transform m_Foot; + + private List m_Colliders = new List(); + + public Transform foot + { + get + { + return m_Foot; + } + } + + public bool isOnGround + { + get + { + return m_Colliders.Count != 0; + } + } + + private void OnTriggerEnter(Collider other) + { + if (!m_Colliders.Contains(other)) + m_Colliders.Add(other); + } + + private void OnTriggerExit(Collider other) + { + if (m_Colliders.Contains(other)) + m_Colliders.Remove(other); + } + + private void OnTriggerStay(Collider other) + { + } + + } + +} -- cgit v1.1-26-g67d0