Search Unity

Character Equipment Slots - Empty Game Objects - Child Objects inventory system

Discussion in 'Scripting' started by Deadlyapples, Mar 12, 2018.

  1. Deadlyapples

    Deadlyapples

    Joined:
    Dec 30, 2013
    Posts:
    54
    So I am working on an object hierarchy based inventory system where by you pick up objects with the characters hand, you can equip for example a helmet, your character places this helmet on the characters head and it is actually tied to an empty game object in the scene and all stats are worked out based on this system.

    I am currently using a simple capsule character controller and simple spheres and cubes to represent items and gear but I am wondering when I get to having animated characters equipping gear how will I get this to work.

    When it comes to a rigged and animated character is it possible to attach empty game objects to specific parts and locations on the characters. So when a character moves these empty game objects move with the character.

    Just looking for some advice. Thanks!
     
  2. TimmyTheTerrible

    TimmyTheTerrible

    Joined:
    Feb 18, 2017
    Posts:
    186
    Yes you can attach empty game objects to the bones of an animated character, and position them, and they will animate with the character.

    How i did my inventory was i created a scriptable object item class. Then for each item i would create an item asset file from said class . The item scriptable would have a link to 3 other prefabs, the world item prefab, the inventory item prefab, and the equip item prefab. The world item prefab would be the one placed in the game world with a rigidbody and trigger collider on it, along with the script to loot the item, etc... The inventory item prefab was mostly the ui version of the item, and this item would get parented to the ui inventory slot. And the equip item would be the version of the item that would get instantiated at the location of the character if the player placed the item in an equippable slot. Equippable slots would require a link to a world transform attached to the character.
     
  3. Deadlyapples

    Deadlyapples

    Joined:
    Dec 30, 2013
    Posts:
    54
    Awesome! :D

    Uploading a video on what I have at the moment and if this is the case as you said above I can expand on what I have so far to include all the armor and weapon slots and to transfer this over to an animated character will be easy!
     
  4. Deadlyapples

    Deadlyapples

    Joined:
    Dec 30, 2013
    Posts:
    54