Advertisement
Guest User

Untitled

a guest
Nov 19th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement