using UnityEngine; public class GroundCheck : MonoBehaviour { GameObject Player; private LayerMask solidLayer; private void Start() { Player = gameObject.transform.parent.gameObject; solidLayer = LayerMask.GetMask("SolidObject"); } private void OnCollisionEnter2D(Collision2D collision) { if (collision.collider.tag == "Ground" || collision.collider.tag == "Platform" || collision.collider.tag == "Tetromino") { Debug.Log("Now standing on "+ collision.collider.name); Player.GetComponent().isGrounded = true; } } private void OnCollisionExit2D(Collision2D collision) { if (collision.collider.tag == "Ground" || collision.collider.tag == "Platform" || collision.collider.tag == "Tetromino") { if (GetComponent().IsTouchingLayers(solidLayer) == false) { Debug.Log("No longer standing on " + collision.collider.name); Player.GetComponent().isGrounded = false; } } } }