I have some code for picking up an item on mouse click but I plan on removing the mouse functionality. Does anyone know how I could edit this to make it on button press instead of a mouse click on the object?
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit))
{
if (Input.GetMouseButtonDown(0))
{
if (hit.transform.GetComponent())
{
Pickup item = hit.transform.GetComponent();
if (PickupDistance(item) <= item.GetPickupRadius())
item.PickupItem();
}
}
}
Thanks,
Dan