diff --git a/Assets/CollisionCheck.cs b/Assets/CollisionCheck.cs index 0f7fd65..a652378 100644 --- a/Assets/CollisionCheck.cs +++ b/Assets/CollisionCheck.cs @@ -1,13 +1,21 @@ using UnityEngine; using System.Collections; +using UnityEngine.UI; public class CollisionCheck : MonoBehaviour { + public Text health; + + public void initText(int hp) + { + health.text = "Health: " + hp; + } + void OnCollisionEnter2D(Collision2D col) { if(col.gameObject.name == "Enemy") { - Debug.Log(gameObject.GetComponent().removeHP(1)); + health.text = "Health: " + gameObject.GetComponent().removeHP(1); } } } diff --git a/Assets/Scripts/PlayerBehavior.cs b/Assets/Scripts/PlayerBehavior.cs index 976ee45..bcd5902 100644 --- a/Assets/Scripts/PlayerBehavior.cs +++ b/Assets/Scripts/PlayerBehavior.cs @@ -22,6 +22,7 @@ public class PlayerBehavior : MonoBehaviour { rb = gameObject.GetComponent(); anim = gameObject.GetComponent(); + gameObject.GetComponent().initText(gameObject.GetComponent().getHP()); } // Update is called once per frame