Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.UI;
- public class PlayerCollision : MonoBehaviour
- {
- public PlayerMovement movement;
- public Image heartHUD;
- public Text healthStatus;
- void Update()
- {
- healthStatus.text = "100";
- if (movement == false)
- {
- healthStatus.text = "0";
- }
- if (Input.GetKeyDown("h"))
- {
- healthStatus.enabled = false;
- heartHUD.enabled = false;
- }
- else if (Input.GetKeyDown("j"))
- {
- healthStatus.enabled = true;
- heartHUD.enabled = true;
- }
- }
- private void OnCollisionEnter(Collision collision)
- {
- if(collision.collider.tag == "Obstacle")
- {
- movement.enabled = false;
- FindObjectOfType<GameManager>().EndGame();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement