Download

Multiplayer TopDown Survival Kit

Now available on the marketplace! Marketplace Link

Highly customizable multiplayer template for creating TopDown or Survival games.

** User Guide **

Features

[spoiler]
• Twin-Stick-Shooter controls
• day&night cycle including clock with customizable format
• climate system with fluctuating world temperature and temperature modifying areas

**Multiplayer system **
• create and join multiplayer sessions
• reconnect to sessions with your character being remembered by the server (identified by the playername)
• scoreboard with customizable sorting order

**SaveGame system **
• separate SaveGame objects for the game and for the options
• variables of a player’s character can be saved bound to the level or saved bound to the SaveGame.

**Realistic hunger, thirst and body temperature system based on thermodynamic laws **
• human body tries to regulate his body temperature by shivering and sweating
• drinking does affect the body temperature depending on the temperature and amount of the fluid
• clothing modifies how much the air temperature does affect the body temperature
• PostProcess effect covering the edges of the screen warning the player that he is close to becoming hypothermic / overheated.
**
Inventory, Equipment, Crafting and Building system **
• optimized for low usage of network bandwidth in multiplayer games
• move, swap, split, stack, resize, use, equip, unequip, drop and pick up
• lootable actors with customizable random loot
• add or remove craftable items and modify their crafting cost and time to craft during the game

Please note: The Twin-Stick-Shooter controls and the example map are designed for TopDown games. Everything else will also work in Third-Person and First-Person games.
[/spoiler]

FAQ

Where can I find the tutorials?
This pack currently has 11 Blueprint Editor Tutorials. These tutorials cover the character, inventory, equipment, crafting and building, weather, food water and temperature and interacting with actors and outlining them, start menu, multiplayer system and the SaveGame system. You can find them under Edit->Tutorials in the level overview or under /Blueprints/Tutorials. These tutorials cover where to find specific logic, how it’s set up and explain how things like inventory items, equipment slots or wind speed can be quickly added. If anything remains unclear after reading the tutorials please contact me about your issues. I will always help you to realize your vision and be thankful for all feedback that will help me to improve the documentation.

Can I play with a friend over the network?
This system uses the Online Session nodes and therefore you can. Check out the Unreal Engine 4 documentation to find out more about the Online Session nodes.

Will basic AI (for example zombies) be added to this pack?
I will consider that in the future but it’s not at the top of my list. I will keep focusing on features that are more related to each other first. Such an AI would have nearly no relations to the existing features and would therefore pretty easy to integrate into the template for everyone.

The widgets stop updating after they have been drag&dropped
I am aware of this issue but this is an Unreal Engine bug. This issue is documented in the report UE-31777. Epic will hopefully fix that bug in the near future.

Additional Tutorials

Drop / Pick up item actors outdated since v1.2.0
Add a new item
Remove the survival part (day&night cycle, temperature, food, water)

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.

v1.2.0 (02-14-2017):
New Features
[spoiler]
Near game-ready StartMenu
This includes a singleplayer (create new game, load singleplayer SaveGame), a multiplayer (Host new game, Host multiplayer SaveGame, Join game and an options menu (default options for saving, full graphics options). The StartMenu is designed minimalistic just like the user interface and the same widgets are reused as often as possible so you can change the design quickly as soon as you want to.

Game menu
Ingame a player can open the GameMenu by either pressing Esc or F1. The widget used for this menu are the same as that in the StartMenu so the style will automatically be consistent. You can choose if the screen should be blurred while the GameMenu is open. In singleplayer games opening the GameMenu pauses the game.

Multiplayer system
The Multiplayer system uses the Online Session nodes with all functionality these nodes offer. In addition to the JoinSession node a game can be joined by directly entering the host’s IP. The server will load the last status (including inventory, equipment, crafting manager) when a player who’s known to the server connects. The server even differentiates on which levels a player is already known and you can quickly change what variables will be remembered bound to the level and what variables will be remembered bound globally over all levels. Each player can chose some player specific variables combined in a struct when joining a game. This variables are used to define what type of character the player wants to play. Whenever a player respawns these variables will be used to set up the new spawned character aswell.
A player is identified on the server by the playername he chose. There is no unique way to identify a player without an online subsystem. Before releasing the game you will most likely want to replace this with a unique ID of the online subsystem (e.g. steamID).

SaveGame system
The SaveGame system is directly connected to the multiplayer system. Whatever variables you choose to be bound to the level or bound globally bound over all levels will be saved and loaded just like that. In addition the SaveGame system saves and loads the inventory of all actors with an inventory in the level, the transform and remaining burning duration of campfires and the Open/Closed status of all actors that inherit the interface BP_iOpenable (windows, doors). The SaveGame system also saves and loads game specific variables that define the rules of a game (e.g. difficulty, weather). At last it also saves some variables like the current level, date of save and the ingame time.
The options (SaveGame, video options) are saved in a different SaveGame object so these are remembered after restarting the game.

Scoreboard
The template now includes a scoreboard. This scoreboard will automatically display all online player and their chosen name. The scoreboard displays the name of a player, his score, deaths and ping. Score and ping are stored in the player state and (per default) increased whenever one player killed another player / dies. The scoreboard can be sorted in ascending or descending order for each of its attributes. Per default a player can change this order by clicking on one of the buttons of the scoreboard.

Inventory system

  • The inventory system now uses a DataTable to store the information of items that don’t vary between instances of an item. This nicely reduces the memory usage (especially from empty slots) in case of very large levels with many inventories.
  • Items can now be dropped and picked up
    [/spoiler]

Changes
[spoiler]

  • The inventory system now only replicates an inventory when a player opens it instead of replicating neutral inventories to everyone. This is the absolut minimum information a client can get from the server and therefore as proof to cheaters as the rest of the template. This does also fix an issue of the inventory system regarding network relevancy that could’ve occured earlier.
  • The template now follows Allar’s style guide as much as the submission guidelines allow it.
    [/spoiler]

v1.2.1 (02-24-2017):
Changes

  • The class BP_InvItem_Buildable is now removed. The campfire and other buildable items now directly inherit from BP_InvItem. They become buildable if both of the buildable variables in the DataTable DT_Items are set.
  • Some Server RPC events are not longer RPC events and start with a SwitchHasAuthority node instead.

v1.2.2 (04-13-2017):
Changes

  • The component BP_Inventory now contains a function for resetting the inventory so it can be looted with randomly generated items again. Calling this function will only have an effect if called on the server and when no player does currently has the inventory opened.
  • The type of the attachable equipment meshes is now skeletal mesh.
  • Fixed a bug caused by the editor that resulted in a warning in BP_PlayerCharacter after each editor restart before compiling.

Does the Fog of war come with the kit or no?

Super tempted to pick this up. :slight_smile:

Hehe, no sorry :wink:

The Classic TopDown Fog of War pack was more work than this complete pack and a lot more difficult.

I’m having trouble with: “In that event (run it only on server) you spawn an actor of class of the newly created actor class variable. Now you want to remove the inventory item. You can copy paste the last part of the function UseItem in BP_PlayerCharacter to remove it with the correct replication.”

I Don’t know how to GET the actor variable and plug it into the new node we created. I Don’t know exactly what part i need from the Use Function in player bp. It would be helpful if you can Send some pictures on how to do these steps cause i’m pretty lost.

Dropping / picking up items isn’t implemented in the game because it’s rather unusual for TopDown games. But you can pretty quickly implement it on your own!

Here is a step by step tutorial how to drop / pick up item actors:

  1. Add a variable of type Actor class to BP_InvItem.

  2. Create the private function DropActor in BP_PlayerCharacter:

444fe05d4023ba94be4b47c42eac25a9c91b210a.png

  1. Create an event that runs on server and calls the new function:

d14b4deb0241c1574ac75b55467443adc0614231.png

  1. Edit the OnDrop function of BP_UI_MainHUD like this:

8e01f6a70d5ec630f76123209a0da674d14c3e45.png

  1. Create an actor (for example a medikit) with a static mesh for any of your inventory items and ensure it replicates. You might also want to enable SimulatePhysics for that static mesh.

DropPickupActorsTutorial_4.png

  1. Choose an item ( for example the medikit) and set the new actor class variable (created in step 1) to the newly created actor.

Now you should already be able to drop that item by drag & dropping it anywhere in the world (not on any widget).

  1. Create a new Blueprint Interface BP_IPickupable with a function that returns a variable of type BP_InvItem class:

60f0e2335420e138cd1e5aa26f23dda2a4b1d001.png

  1. Add the interface to the medikit and implement its function:

  1. Create the private function Pickup in BP_PlayerCharacter:

bc96b30ec8672891f6885365ae1b66e8cae8c58f.png

  1. Add a hotkey for picking up items under Edit->Project Settings->Input->Action Mappings. Name it Pickup for example.

  2. Create the following 2 events:

78fa14f688b79fc9baa7ca2cd35f0957500602a8.png

You can now drop and pick items up!

In TopDown games you might want to check if the distance between the player character and the hit actor is smaller than a specific value in the function Pickup. And additionally send a LineTrace from the player character to the hit actor in order to ensure the player can’t pick up actors behind walls. Please note that on the example map you have to choose a trace channel that isn’t blocked by the roof of the house (and it’s hidden mesh that ensures correct shadow casting) or change the collision presets of those 2 meshes.

In FirstPerson games you want to replace tracing from the camera into the cursor position by tracing from the camera into the camera direction (CameraManager->GetActorForwardVector). Because the GetActorForwardVector is normalized (has length 1.0) you want to multiply it with a float value that defines your maximum “pickup range”.

I Can’t drop items for some reason. The event “Drop Inv Item” gets called, but when i drag an item out, nothing happens. The string gets printed, but thats about it.

BP_UI_MainHud

DropInvItem
7ac3eb44a82afd90748505d83bdf01112deecf59.png

Drop Item Function
54dc89e8f0ad19d2668fb8e115ff666e406c60a3.png

What am i doing wrong? I Can’t get the item to drop.

Please make the custom event DropInvItem Reliable. This event is important to gameplay so it should be reliable in order to ensure it’s been replicated.

If this is still not working, please test with PrintString what is the last node that is been executed. Your function looks correct what works on my end.

Do you have set the ActorItem variable of the item you’re trying to drop to the actor you created?
Does this actor have a static mesh so you are sure you will see it when it’s spawned?
Is the item removed from the inventory and only not spawned?

I enabled “Reliable” and it still isn’t working. It prints the string and thats it. Nothing gets removed from the inventory. Heres a video of what it does: - YouTube

Can you check if the branch that checks if Actor Item IsValidClass is True? Using a PrintString node for example. You might haven’t set this variable in the items you want to drop. I guess you could’ve missed something in step 6.

That worked lol the actor i was trying to drop didn’t have it’s actor class set. I’m gonna follow along the rest of the tutorial and tell you if i run into any problems.

Thank you!!! THIS IS AMAZING!! I’ve just finished it. It’s awesome. You should include this setup in your system optionally. Or, you should sell the inventory and crafting system seperately, cause this is amazing. It’s the reason why i bought this system, and you really saved me here. I Couldn’t thank you enough for this system!

Also, i’m using this system on Mobile, so i can’t right click to use items. Is there anyway i can double tap the items to use them? and if not, is it possible to create another inventory slot, and whenever i drop the item in the new inventory slot, it uses the item? if any of these are possible, could you explain how to set it up? thanks.

Thank you for your kind words, glad you enjoy it!

I can’t tell you about the double tap because I don’t have mobile development experience but I would wonder if there isn’t a way.

This would be super easy. Not an inventory slot but just create a new widget. Override the function OnDrop. In that function cast the Operation to BP_InvItemDrag, if that is successful call the function UseItemInSlot Of BP_PlayerCharacter with the Inventory and Slot variables of the BP_InvItemDrag operation. You will also need a GetPlayerCharacter node and cast it to BP_PlayerCharacter in order to be able to call the function UseItemInSlot. Now this should already work.

I’ll try it now

It works! but it also drops the item if the item isn’t usable.

and one last thing, and i won’t bug you anymore. How do i stop the menus from dragging? i see the settings in my player character, but they don’t affect anything…

Did you check the return value of the OnDrop function to true after you’ve called the UseItemInSlot event? If you didn’t the game thinks this drop operation is unhandled and sends it up to the MainHud. This would explain the issue.

Don’t worry, I like to help. Those kind of variables and many others are read from the gamemode. There you have a nice overview of variables and you’re able to quickly edit them to your needs. If you change it there it will work.

Okay, i’ll look into that. Here’s a harder question: How do i add weight to the items?

This will need some work depending on how you want it to be implemented. But this are the basic steps that would need to be done:

  1. Create a variable for the weight to BP_InvItem and a variable MaxWeight for the maximum weight of the inventory in BP_Inventory
  2. Create a pure+const function GetInventoryWeight in BP_Inventory that calculates the current weight of the inventory. Easiest would be to loop over all slots, check if the current slot is not an empty slot and add the weight of the current slot times the amount on its stack to a local variable for the sum of the weight. In the end return the sum.
  3. Add a branch at the beginning of the function AddItemInSlot that tests if the inventory can still carry the new item. Basically testing if GetInventoryWeight + Weight of the item to add is less equal than MaxWeight.
  4. Now you will also need to clamp the variables ItemsToMove / AmountToMove in the functions AddToStack / SwapItems to the maximum amount of items of the specific type the inventory can still carry.

There might be things that I’ve probably missed. Also this would not take currently equipped items into account. And (though physically this makes no sense) if a craftable item weighs more than the sum of the items needed to craft it, you would also need to check that before crafting.

I’ll look into that and tell you how it goes. How do i look at items and text appears with the items name, like skyrim?