[UDK] Clarity on the default inventory system, and removing a weapon

Started by
2 comments, last by ratrace135 11 years, 1 month ago
Hey guys, I'm just trying to do a simple test where MyPlayerController has a function that can remove the item in the current user's inventory. I'm not using any specially built system of inventory, I'm using the default Unreal Tournament inventory system. So the idea is that if the player pawn touches some actor (let's call it MyWeaponRemover), then MyWeaponRemover will call this function on MyPlayerController and remove the weapon they have equipped. (i.e If they had only their current weapon, now they would have nothing.) With what little I knowI guess it'd look something like:
function RemoveWeapon()
{
    DefaultInventory(0)=None;
}
How far off would I be if I said that? I've done some searching for the topic of the default inventory system, but I've not seen much info. I've also seen many guides on how to make my own inventory system, but I'm on a tight deadline and don't have the time to make a completely new inventory. Any advice or suggested resources?
Advertisement

The DefaultInventory's given to the player when they're spawned. After that, the weapon will be in the InventoryManager, and you'll have to use the DropFrom(vector StartLocation, vector StartVelocity) function from the inventory class to get the pawn to throw out its current weapon... Luckily, that's already done for you with the PlayerController's ThrowWeapon() function (which calls the Pawn's ThrowActiveWeapon() function), so you don't need to make the function at all. biggrin.png

ratrace, thanks for that! I'm unfortunately not able to test that any time soon, so I can't answer my next question, but what I want to happen is for the weapon to be removed from the game, not just dropped somewhere on the ground. Would these functions do that, or need I use another built-in function, or make one of my own?

Ahh, no, ThrowWeapon() would spawn a DroppedPickup in its place. You'll have to remove the weapon directly with the InventoryManager's RemoveFromInventory(Inventory ItemToRemove) function. I wrote out what to do, but then where's the fun in that? I'll let you have your fun figuring it out instead of just giving you the answers tongue.png

This topic is closed to new replies.

Advertisement