Hi (806493)

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);
}

}

Please use code tags: Using code tags properly

How to report problems productively in the Unity3D forums:

http://plbm.com/?p=220

Help us to help you.

@swineek

Also, “Hi” doesn’t tell anything about your problem…

Please read the forum rules and post properly. Provide useful information, proper title and correct formatting. Closed for low effort posting.

1 Like