| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class PlayerFoot : MonoBehaviour
- {
- public bool TrigGround
- {
- get
- {
- return trigGroundList.Count > 0;
- }
- }
- public PlayerController player;
- public List<GameObject> trigGroundList;
- private void Awake()
- {
-
- }
- private void FixedUpdate()
- {
- if (!player)
- {
- return;
- }
- for (int i = 0; i < trigGroundList.Count; i++)
- {
- if (trigGroundList[i] == null)
- {
- trigGroundList.RemoveAt(i);
- i--;
- }
- }
- }
- private void OnTriggerEnter(Collider other)
- {
- if (other.CompareTag("Plane") || other.CompareTag("Ground"))
- {
- trigGroundList.Add(other.gameObject);
- }
- }
- private void OnTriggerExit(Collider other)
- {
- for (int i = 0; i < trigGroundList.Count; i++)
- {
- if (trigGroundList[i] == other.gameObject)
- {
- trigGroundList.RemoveAt(i);
- i--;
- }
- }
- }
- }
|