Forum begins after the advertisement:
-
::This will be officially solved in the next part (Part 32), but you can fix it here and now.
So there’s a bug when you are holding an item in your hand, and when you pick up an object, whatever you are currently holding gets overwritten. To fix this, we will first move whatever the player is holding to the Inventory.
Add the following if statement to the Pickup
function of InteractableObject
:
public virtual void Pickup()
{
//Call the OnInteract Callback
onInteract?.Invoke();
//Check if player is holding anything
if (InventoryManager.Instance.SlotEquipped(InventorySlot.InventoryType.Item))
{
//Bring it over to the inventory
InventoryManager.Instance.HandToInventory(InventorySlot.InventoryType.Item);
}
//Set the player's inventory to the item
InventoryManager.Instance.EquipHandSlot(item);
//Update the changes in the scene
InventoryManager.Instance.RenderHand();
//Disable the prompt
OnMoveAway();
//Destroy this instance so as to not have multiple copies
GameStateManager.Instance.PersistentDestroy(gameObject);
}