using System.Collections; using System.Collections.Generic; using UnityEngine; public class TouchingDirections : MonoBehaviour { public ContactFilter2D castFilter; public float groundDistance = 0.05f; Rigidbody2D rb; public GameObject rotorGO; BoxCollider2D touchingCol; Animator animator; Animator animator_rotor; RaycastHit2D[] groundHits = new RaycastHit2D[5]; [SerializeField] private bool _isGrounded; public bool IsGrounded { get { return _isGrounded; } set { _isGrounded = value; animator.SetBool(AnimationStrings.Player.IsGrounded, value); animator_rotor.SetBool(AnimationStrings.Player.IsGrounded, value); } } void Awake() { rb = GetComponent(); touchingCol = rb.GetComponent(); animator = rb.GetComponent(); animator_rotor = rotorGO.GetComponent(); } // Start is called before the first frame update void Start() { } void FixedUpdate() { IsGrounded = touchingCol.Cast(Vector2.down, castFilter, groundHits, groundDistance) > 0; } }