Added project
This commit is contained in:
20
Platformer/Assets/Scripts/GroundDetection.cs
Normal file
20
Platformer/Assets/Scripts/GroundDetection.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class GroundDetection : MonoBehaviour {
|
||||
|
||||
public bool isGrounded { get; private set; }
|
||||
|
||||
private void OnCollisionStay2D(Collision2D other) {
|
||||
|
||||
if (other.gameObject.CompareTag("Platform") || other.gameObject.CompareTag("Enemy")) {
|
||||
isGrounded = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionExit2D(Collision2D other) {
|
||||
if (other.gameObject.CompareTag("Platform") || other.gameObject.CompareTag("Enemy")) {
|
||||
isGrounded = false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user