-
Notifications
You must be signed in to change notification settings - Fork 0
/
HealthBoost.cs
43 lines (37 loc) · 1.09 KB
/
HealthBoost.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class HealthBoost : MonoBehaviour
{
[Header("Health Boost")]
public PlayerScript player;
private float HealthToGive = 120f;
private float radious = 2.5f;
[Header("Sound")]
public AudioClip HealthBoostSound;
public AudioSource audioSource;
[Header("HealthBox Animator")]
public Animator animator;
public GameObject pickupUI;
private void Update()
{
if(Vector3.Distance(transform.position, player.transform.position) < radious)
{
Debug.Log("near");
pickupUI.SetActive(true);
if (Input.GetKeyDown(KeyCode.F))
{
animator.SetBool("Open", true);
player.PresentHealth = HealthToGive;
player.healthBar.SetHealth(HealthToGive);
//sound effect
audioSource.PlayOneShot(HealthBoostSound);
Object.Destroy(gameObject, 1.5f);
}
}
else
{
pickupUI.SetActive(false);
}
}
}