top of page

Lost and found items

I bought the UE4 marketplace content by Siger Lee TopDown RPG Inventory System, mainly because it resembles the inventory of the game I work on, Path of Exile.

There is a problem with the DropItem functionality in this system, in which the item can get hidden behind geometry and become unclickable (due to how highlighting works I guess). This is actually a large oversight, especially given the demo scene features big grey blocks that are perfect for losing items behind.

To reproduce this, equip an item like the Chestplate, then open the inventory and drag and drop to discard it. Repeat the drag and drop till the item's location is unfortunate and you can't click it. It shouldn't take many tries, especially if you aren't standing near some of the big grey boxes.

Important to note: This shouldn't put you off buying this system, as you will still have to do plenty of modifications to it anyway, and fixing this case may not be the hardest.

There are various ways to fix where objects can land. One way might be to have items nearby the player list in a UI widget you can grab them from. Or you could add an array of attached Volumes around the player that test for overlaps and collision before letting objects fall inside them.

Here's a little demo of the problem (I actually lost the item on my first try).

My fix is a little clunky in that the object, once it finds itself unclickable, attempts to move to a new location, so potentially a stuck item could dance around quite a while finding a better spot (which is not ideal). I just wanted to see if I could make sure no item can get stuck, at this stage. I believe it would be best to not randomise where objects can spawn but have a few set offsets from the player and test only those and only drop if at least one is unblocked.

Anyway, here's the outcome of choosing a random location on navigation mesh close to the player, and then tracing the heck out of it.

And here is the BP (it's taken from the marketplace content, but it's only a small fraction, plus the changes here won't make much sense without perusing the TopDown RPG Inventory) so I'm assuming if you care about this, you probably already bought it.

First, we only want items to drop on the Nav Mesh, so you can reach them, even before worrying about whether you can click on them. When you choose Build > Navigation, you'll get a Recast Nav Mesh actor added in your level. We want to reference that in our DropItem function. To help with that, go to Project Settings > Navigation System and add under Agents an entry in Supported Agents (the defaults for the entry would be fine).

In Siger's blueprints, find the DropItem function in BPC_InventoryManager. You should be able to get there using Find Results 'Drop Item' and setting the scope to global (with the binoculars icon).

After the item is spawned, its Target location is sent to BP_BaseItem > OnDrop and it Lerps the item from the player's location to the target location with some bounce and roll math.

I deleted the bounce, and added the Trace to make sure the location is in view of the camera.

Even then sometimes the object could end up out of view, so I went a little further and added a second check to verify the final placement of the item after it finishes moving, so that if it finishes blocked it is forced to push the object to a new location and check again. Since we loop back each time the trace fails, this could go on forever, but in practice it sorts itself out almost immediately, as the video shows. [But take care].

The risk here is that we're calling the function inside itself (which is allowed but can cause an infinite loop). That's why I think, if you want to do more than just prevent the clickable blockage, a more robust solution here would be to redo the DropItem system to use some player-attached Volumes that surround the player and only allow dropped items to land in them if the volume isn't overlapping anything. That way you get a Can't Drop warning instead of a dropped item that dances around weirdly or, even worse, an item that is lost for ever.

Featured Posts
Recent Posts
Search By Tags
Follow Us
  • Facebook Basic Square
  • Twitter Basic Square
  • Google+ Basic Square
bottom of page