SHARE
TWEET

Untitled

a guest Nov 19th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using UnityEngine.UI;
  3.  
  4. public class PlayerCollision : MonoBehaviour
  5. {
  6.     public PlayerMovement movement;
  7.     public Image heartHUD;
  8.     public Text healthStatus;
  9.  
  10.     void Update()
  11.     {
  12.         healthStatus.text = "100";
  13.  
  14.         if (movement == false)
  15.         {
  16.             healthStatus.text = "0";
  17.         }
  18.  
  19.         if (Input.GetKeyDown("h"))
  20.         {
  21.             healthStatus.enabled = false;
  22.             heartHUD.enabled = false;
  23.         }
  24.  
  25.         else if (Input.GetKeyDown("j"))
  26.         {
  27.             healthStatus.enabled = true;
  28.             heartHUD.enabled = true;
  29.         }
  30.     }
  31.  
  32.     private void OnCollisionEnter(Collision collision)
  33.     {
  34.         if(collision.collider.tag == "Obstacle")
  35.         {
  36.             movement.enabled = false;
  37.             FindObjectOfType<GameManager>().EndGame();
  38.         }
  39.     }
  40. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top