From 115f77bda0246a00f6e17469685c67746bdbd29d Mon Sep 17 00:00:00 2001 From: nirav Date: Sat, 12 Dec 2020 07:18:36 +0000 Subject: Initial commit --- Assets/Scripts/Player/GroundCheckScript.cs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 Assets/Scripts/Player/GroundCheckScript.cs (limited to 'Assets/Scripts/Player/GroundCheckScript.cs') diff --git a/Assets/Scripts/Player/GroundCheckScript.cs b/Assets/Scripts/Player/GroundCheckScript.cs new file mode 100755 index 0000000..4dbace7 --- /dev/null +++ b/Assets/Scripts/Player/GroundCheckScript.cs @@ -0,0 +1,25 @@ +using UnityEngine; +using System.Collections; + +public class GroundCheckScript : MonoBehaviour { + + public PlayerMovementScript player; + + void OnTriggerEnter2D(Collider2D col) + { + if (col.tag == "Ground" || col.tag == "Platform") + player.grounded = true; + } + + void OnTriggerStay2D(Collider2D col) + { + if (col.tag == "Ground" || col.tag == "Platform") + player.grounded = true; + } + + void OnTriggerExit2D(Collider2D col) + { + if (col.tag == "Ground" || col.tag == "Platform") + player.grounded = false; + } +} -- cgit v1.2.3