using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Foot : MonoBehaviour
{
    public bool TrigGround
    {
        get
        {
            return trigGroundList.Count > 0;
        }
    }

    public List<GameObject> trigGroundList;

    private void Awake()
    {
        
    }

    private void FixedUpdate()
    {
        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"))
        {
            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--;
            }
        }
    }
}
