AlexRaynor

5.5

Nov 12th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class GroundDetection : MonoBehaviour
  6. {
  7.     [SerializeField] private bool isGrounded;
  8.  
  9.     public bool IsGrounded { set { isGrounded = value; } }
  10.  
  11.  
  12.     private void OnCollisionEnter2D(Collision2D col)
  13.     {
  14.         if (col.gameObject.CompareTag("Platform"))
  15.         {
  16.             isGrounded = true;
  17.         }
  18.     }
  19.  
  20.     private void OnCollisionExit2D(Collision2D col)
  21.     {
  22.         if (col.gameObject.CompareTag("Platform"))
  23.         {
  24.             isGrounded = false;
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment