0
\$\begingroup\$

In my game you don't have inventory slots, you can hold two things if your player has 2 arms and so on, you can hold more things if you equip a bags on your belt or backpacks... and you can carry even more things if you buy a horse or a carriage or even a ship to sail the waters while trying to avoid other players or pirates... carrying stuff is very much a great part of the game.

and you can also carry npcs or your fallen or injured teammates.

so I was thinking of methods to do this, is this as simple as taking the model of a player/npc/object and adding it as a child of the carrying player and apply to the carried thing the animation loop that constantly plays the pose ''carried" ?

I'm asking becase yesterday i wasted like 3 hours assuming something was easy and basic only to find out it is incredibly stressful.

enter image description here

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

This can be coded exactly like an inventory system, but limited to 2 items and animated to show the item being carried.

An inventory is just an array of items. Here's some C# pseudo code:

Class Inventory
{
    Item[] inventory {get; set;}
    
    Inventory() //empty inventory
    {
        inventory = new[2];
        inventory[0] = new();
        inventory[1] = new();
    }
    
    void AddItem(Item item)
    {
        if (inventory[0] == null) 
        {
            inventory[0] = item;
        }
        else if (inventory[1] == null)
        {
            inventory[1] = item;
        }
        else
        {   
            Console.log = "Maximum carrying capacity already reached."
        }
    }
}
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .