I am trying to make a hold object function to my game, i can pick up a single item (objective) but then i cant drop it
```cs
void HoldObject()
{
// is on raycast, E was pressed, isnt holding
if (CanInteract() && interactAction.WasPressedThisFrame() && !isHolding)
{
if (itemToHold == null) return;
isHolding = true;
Debug.Log("Grab: " + itemToHold);
itemToHold.GetComponent<Rigidbody>().useGravity = false;
itemToHold.transform.SetParent(objectHandle.transform);
itemToHold.transform.position = objectHandle.transform.position;
} // E was pressed, is holding something
if (interactAction.WasPressedThisFrame() && isHolding)
{
if (itemToHold == null) return;
isHolding = false;
Debug.Log("Drop: " + itemToHold);
itemToHold.GetComponent<Rigidbody>().useGravity = true;
itemToHold.transform.SetParent(originalParent.transform);
}
}
public bool CanInteract()
{
RaycastHit hit;
if (Physics.SphereCast(transform.position,
sphereRadius,
transform.forward,
out hit,
interactDistance,
interactable))
{
itemToHold = hit.collider.gameObject;
return true;
}
else
{
return false;
}
}