I have done script for picking up item and i want this item heal my player but i don t know how.
Script with player health is called “PlayerHP” and health is named “currHealth” pleaese help
using UnityEngine;
public class PickUp : MonoBehaviour
{
public Transform theDest;
public Transform butla;
void Update()
{
if (Input.GetKeyUp(KeyCode.E))
{
if ((Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out RaycastHit hit)) && (hit.transform == transform))
{
Debug.Log(hit.distance);
if (hit.distance < 5)
{
GetComponent().useGravity = false;
GetComponent().enabled = false;
transform.position = theDest.position;
transform.parent = GameObject.Find(“Destination”).transform;
if(Input.GetKeyUp(KeyCode.F))
{
}
}
}
}
if (Input.GetButton(“Fire2”))
{
this.transform.parent = null;
GetComponent().useGravity = true;
GetComponent().enabled = true;
butla.transform.rotation = Quaternion.LookRotation(Input.acceleration.normalized, Vector3.up);
}
}
public void Potion(float currHealth)
{
Debug.Log(currHealth);
}
}