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.CompareTag("Ground") || collision.collider.CompareTag("Platform") || collision.collider.CompareTag("Tetromino")) { Debug.Log("Now standing on "+ collision.collider.name); Player.GetComponent().isGrounded = true; } } private void OnCollisionExit2D(Collision2D collision) { if (collision.collider.CompareTag("Ground") || collision.collider.CompareTag("Platform") || collision.collider.CompareTag("Tetromino")) { if (GetComponent().IsTouchingLayers(solidLayer) == false) { Debug.Log("No longer standing on " + collision.collider.name); Player.GetComponent().isGrounded = false; } } } }