Search Unity

Object with an inventory

Discussion in 'Scripting' started by M_Keyla_M, Jun 5, 2020.

  1. M_Keyla_M

    M_Keyla_M

    Joined:
    Dec 24, 2014
    Posts:
    57
    Hey everyone!
    I wish to create a potion crafting system.
    I had the idea to have a cauldron have its own inventory. The (third person) player adds objects to that inventory by dropping objects into the pot (hitting the collider)
    The crafting system uses that inventory to create potions.
    The only issue is that I’m very stuck with getting the cauldron to work with an inventory. I already made a UI but I don’t get how to make the cauldron register when the object hits the collider and to add that object to the UI
    Any tips? Or help? I really suck at scripting
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,752
    It might be better to have the cauldron scanning all things you're throwing near the water, and when one gets close enough, add it to the inventory and destroy (or hide) the actual in-game thing. You COULD do it with colliders but it's probably a lot more work.

    Distance can be calculated with Vector3.Distance() given the center of the cauldron liquid blob and the inventory item. That's how I would do it in any case.
     
  3. M_Keyla_M

    M_Keyla_M

    Joined:
    Dec 24, 2014
    Posts:
    57
    That’s smart! But I still don’t get how to actually script that though...