Forum begins after the advertisement:
-
::If you want it to just auto-collect the items if the player is near them instead of having to click, simply add a boolean in InteractableObject autoCollect
. Then in the OnInteractableHit add a check for whether the autoCollect is checked, if so, run the pickup function. It will look something like this:
if(other.tag == “Item”)
{
//Set the interactable to the currently selected interactable
selectedInteractable = other.GetComponent();
if(selectedInteractable.autoCollect)selectedInteractable.Pickup();
return;
}
::hi, thank you for posting this tutorial. i tried to applied on the script on the OnInteractableHit
method like this :
if (other.tag == "Item")
{
selectedInteractable = other.GetComponent<InteractableObject>();
if (selectedInteractable.autoCollect)
{
selectedInteractable.Pickup();
}
else
{
selectedInteractable.OnHover();
}
return;
}
but the item (e.g. egg or milk) isn’t auto collect, i have to tap the item to collect, can you help me?
Thanks
::Hi Fathurrachman,
Check if the item has autoCollect checked in the prefab. If it is checked, does the OnHover behaviour run anyway?
Advertisement below: