Multiplayer TopDown Survival Kit

It’s a little late here in germany to get back at pc at the moment but in case you can’t wait: Take a look at how interactable actors are outlined (I guess you want to outline items that can be picked up anyway?). You can find that nodes in a collapsed graph in EventTick of BP_PlayerCharacter if I remember correctly. You would only need to spawn a text for the actors name as long as the sphere (or line?) trace hits that item actor. You will need a branch there to check if the hit actor does implement the interface BP_iPickupable.

I Ran into a new weird issue… Whenever i unequip, it duplicates the item into the inventory and doesn’t unequip. idk what i did (I Didn’t really do anything) but Heres a video of the problem. [video]https://youtu.be/9LGIB-ISW5U[/video]

This could be hard to debug from afar but here are a few questions that might help narrowing down where the nodes are broken.

Does this also appear when doubleclicking an equipment item to unequip it?
Have you done any changes to SwapEquipItems?
Is SwapEquipItems running twice for any reason when you unequip an item?
Have you done any changes to the OnDrop function of BP_UI_InventorySlot?

I Fixed it. it was probably a hud issue. Anyways, i’ve tried to follow your instructions for a weight system, but it didn’t really work out for me too good.

Hi, can you add throwing\selection of loot to upgrade?

I think you mean dropping and picking items up? This is rather unusual for TopDown games and I will avoid implementing logic many won’t need to keep everything clear and easy as it is.

I am sure everyone can easily implement that following my posted step-by-step tutorial: Drop / Pick up item actors.

Just wanted to inform you all that a small update is now online since a few days. 3 bugs you probably didn’t even notice are fixed now. A major update including a starting menu, creating and joining network sessions and more is in the works aswell!

Changelog

v1.1 (12-22-2016):

  • The 12 hour format of the clock wasn’t displaying the correct hour. This is now fixed.
  • Fixed a bug that was causing the inventory system for one client not working properly when using a dedicated server.
  • Fixed a bug that was causing the temperature system for one client not working properly when using a dedicated server.

Hi! This crafting system works amazing. Have you played FALLOUT 4? Well if you have, there’s this feature where you’re able to find any item in the world, and scrap that item for crafting materials. What’s the BEST way in going about doing this? I’d like to drag an item into a slot, (Kind of like an equipment lot) i’d like for it to tell me wich crafting materials i would get if i scrap the item, and when i press “SCRAP”, i’d like to receive those crafting materials and i’d like for the item i scrapped to be deleted. Can you email me at gotgrassct@gmail.com and tell me how i can achieve this?? i’m pretty sure it’s a simple solution. Thanks!!

There are a lot of ways to achieve this. It depends on how you want it to be implemented. An easy way would be simply to use a second BP_CraftingManager component as a scrapping manager. The function names might be a little confusing in the beginning but if you don’t need something special it has all the functionality you need. You will also want to write a new widget class for the scrapping slot. In its OnDrop function you want to cast the operation to BP_InvItemDrag. If the cast was successful you possibly want to move the dragged item back in the slot it’s coming from and check if the item’s class exists in the scrapping manager component. If it does you save a reference to the item and display the crafting materials you get for scrapping with any text widgets. You will need to decide if you want scrapping able to be done from both, the player inventory and the inventory the player is interacting with.

If “SCRAP” is now pressed you want to run an event on the server. That event needs an integer input parameter for the inventory slot index the item is in. You can get that inventory slot index by using the function FindItemSlot. The slot index isn’t directly saved when the item is drag&dropped in the widget because that item could’ve possibly been moved by the player at this point.

This event on the server should (to prevent cheating) again search for the materials you get with scrapping in the scrapping manager component and then remove that item and add the crafting materials. Make sure the scrapping is only done if all scrapping materials can be added after the item is removed. This order is important because removing the scrapped item may free a slot that is needed to add the items you get for the scrapping. When adding one of the items isn’t successful (not enough room in the inventory) you need to remove the previously added items and add back the scrapped item you did just remove. Alternatively you could check if the scrapping can be done beforehand but that is a little more complicated due to the fact that items can be stacked. Make sure the removing / adding is only done on the server and the owning client (in case the server isn’t the owning client) like I’ve did with the whole inventory system to prevent cheating. No client should know about other client’s inventory.


I Added 2 variables to the BP_InvItem: 1. Scrappable Items (Array of BP_CraftingMaterial Class). 2. Scrappable BOOL (If checked true within’ the item class, the item is allowed to be scrapped for materials)

Each item can be setup to have different kind of materials. For example, if i scrap a shirt, i receive cloth. If i scrap a crowbar, i receive 3 metal scraps etc etc

I’m gonna try to use the method you gave me. i’ll tell you how it goes. but i don’t see how using a second BP_Crafting manager will help. Isn’t it easier if i just create a slot that holds the item and place the item in there and the slot reads back those 2 variables (Scrappable items array and Scrappable bool), text block reads that information, when i press scrap, it takes the information from “Scrappable Items Array” and sends it into my inventory and deletes the item. That way i can set each item it’s own Scrappable Materials.

EDIT: This information has become outdated since v1.2. The inventory system of this template uses a DataTable now.

There is generally nothing wrong with your approach. It’s just if you know your game will have large worlds with many inventories and items in the level at the same time you want to reduce the required memory per item. So you don’t want to use too many variables that will always be the same for each instance of a class. Unfortunately blueprints don’t support static variables. Having something like a list that stores a variable for all instances of a class is less memory-heavy but it’s also less versatile. Someone might want to edit the variables on each instance of a class but when you know the scrapping items will be identical for each instance of a class having a list like the CraftingManager will be a better option. I did generally choose a nice balance between easy-to-use, quick during the gameplay implementation, versatility and memory usage for the inventory system.

Yeah, those are some good points, you’re right. But can you break down your scrapping implementation just a little bit more? because reading it, doesn’t make too much sense to me. I’d really appreciate it! as i’m having a lot of trouble with this.
I Wanna do the scrapping from a workbench that has it’s own UI menu that pops up and allows me to scrap the items

I’m not sure what points you’re struggling with. Can you be a bit more specific?

I did just edit my initial explaination post Multiplayer TopDown Survival Kit - Marketplace - Unreal Engine Forums hoping that everything is more clearly now.

Using the crafting manager component was just an idea. The crafting manager was designed to be easily modifiable during the game. So the craftable items and their cost could quickly be modified by reading books for example like in many games. I guess you do most likely not need that for scrapping so you could just use a way more simple “Lookup” list. For example an array of a struct where the struct has one variable of type BP_InvItem for the scrappable and one array variable of the same type for the items you get for scrapping that item.

Allowing crafting / scrapping only from a workbench is super easy. For example add a box / sphere collision to your workbench actor. In the OnComponentBeginOverlap of that collision start with a SwitchHasAuthority node. Only the server should decide if you’re in range of a workbench. Then follow up with a CastToBP_PlayerCharacter node where the input is the OtherActor output of the event. If that is successful you call an event on your BP_PlayerCharacter. This event should be RunOnOwningClient and Reliable. In this event you can then open your crafting / scrapping widget. You will most likely also need a OnComponentEndOverlap in your workbench actor that closes the respective widget again.

Hey everyone, I just wanted to inform you that I haven’t forgotten you!

Quite the contrary! I’ve spent a very large amount of time working on new features. A SaveGame system, a near game-ready Startmenu (and ingame menu) including graphic options, creating new singleplayer or multiplayer games, loading existing singleplayer / multiplayer savegames and joining servers either by IP or by a list available sessions. Leave and reconnect to servers with your player character being remembered! Just to name some of the already implemented new features!

And I’m not even done creating features for the next update! I hope you have the patience to wait a little more.

Hey guys,

happily I can say your waiting will end very soon! The huge update is nearing its completion! All the features are implemented, mostly tested and tutorials for them are written! Only the final testing has yet to be done to ensure the features don’t unintentionally interfere with each other.

Here are some more information about the SaveGame system for you to enjoy during the final waiting! Generally the players and the level are saved separately in the same SaveGame object. You can easily switch levels with the players keeping their whole character! But even if you don’t want that, you can always quickly change what variables you want to be bound to the level and which you want to be bound to the SaveGame. Your character will be remembered when you disconnect and reconnect to a server even when the server switched levels. Even though both do mostly use of course the same logic, the singleplayer SaveGame system has some additions to the multiplayer SaveGame system that will help you to get a nice singleplayer campaign running in case you want it.

You can’t wait anymore? You should know there are even way more features to come than the ones I’ve mentioned so far!

This sounds pretty nice. I saw some blueprints of yours, guess I’ll have to consider getting this one just for learning purposes.

Thanks for the kind words :slight_smile: Always nice to get some feedback.

Hey, you think that things can be removed from the backpack? I just can not get rid of things in your backpack, it is necessary to find a box and throw it. Could you reset to the ground, removing from the pack? Thank you.

I have good news for you. I’ve changed my mind. Dropping and picking items up will now be included in the next update coming soon. Only a small part of the update and implemented rather quickly but I was asked for it multiple times and I will keep listen to your guys feedback.

Thank you very much!