I’m glad you were able to get it resolved promptly
Can this be modified to use for an first person survival game? For example instead of right clicking on a loot crate or body you press E on it instead to access the inventory?
Sorry for the noob question. Just want to be sure I’m buying the right thing considering it says “Action RPG”.
I’m not 100% how the system is set up, however, you can always just get the “on mouse hover” event and switch it out with a “OnEvent Action” + Line Trace (the character must look at it, for example)
Yep Pirate has made a tutorial on how to change interaction to a FPS style game here https://youtu.be/KYB8FnkydNE, but keep in mind this inventory is made for RPG games you will have to put quite a lot of time into it to change it to a Survival style inventory like have, i do all my testing in 3rd person as i like to see the character but my project is a first person game.
List of custom features in my project this just show you what is possible with this inventory system :D.
Hotbar inventory
Item equip on mouse wheel using the Hotbar
Crafting system with blueprints unlocks
Expandable inventory space using backpacks
Health, Food, Water and Energy/Stamina consumables substances.
Placeable world items
Filters for stashes
Item Durability
There are many people like OverRated that are using this in a survival or FPS type game.
Although the Demo UI and controls are more setup to demo an RPG/MMO, the actual Inventory System is designed to be changed and enhanced by you the developer and can fit into any game type that needs an inventory.
If you want to use the Demo content you will need to make changes as it’s impossible to design a system that fits everyone’s own design for their game 100% out of the box. You will also find yourself making changes to the core inventory system to better suite your projects needs.
The more you know about Unreal, networking and blueprinting the easier this will be, but the Inventory System was built to be easy to understand, learn and modify for all skill levels.
Judging by your questions it sounds like you don’t have any experience with Unreal as things like changing controls and keybindings are very basic.
I would suggest first following some of Epic’s tutorial series to learn more about unreal and blueprinting before buying anything on the marketplace.
This will let you see if game development is something you enjoy doing and help you make more informed choices when buying assets off the marketplace.
Hello Pirate,
I recently bought the inventory system and so far it is a lot of fun. Great job!
I have a request/question. Not sure if it’s been brought up yet or not. What would it take to make a container type item? Like a bag or box that can go in your inventory but then open into yet another sub-inventory? Maybe this is already done and I just couldn’t figure out how? If not, it would be a great feature t add to a later version.
Thanks
Yeah it has been brought up before its a lot easier just adding slots to the inventory as the logic’s there already which is what im doing.
Has anyone else tried to set this up when using a dedicated server?
My current problem is when I press E to pick up an item, the item does not get picked up. And it seems I’m getting a None error for Player Inventory when the player connects and I initialize the character. I believe the E problem is stemming from the None error.
This used to work when in PIE using the Run Dedicated Server and Auto Connect to Server flags, but now that I’m running my own processes and only connect via Join Session, it does not work.
Any ideas?
The ‘None’ means that the PlayerInventory reference used by the InventoryManagerComponent is NULL and not set.
This reference should be set when your Player Controller initializes the Inventory System to your Player’s InventoryComponent (EquipmentInventoryComponent)
You can see how this is setup in the original Demo content in this screenshot.
Also in 4.11+ please make sure in your Project Settings you have the correct Global Default Server Game Mode setup.
You can see where to set the Server Default Map and Game Mode in this screenshot.
If all that is fine, I think what could also be causing the issue is Event BeginPlay. Event BeginPlay is not very multiplayer friendly and in the InventorySystem I added a delay to give the server time to replicate to the client before initializing components. This was a simple fix to avoid over complicating things by adding in a Game State Management Framework which is way out of scope for an Inventory System.
For now increase the delay to give the server more time to load in the client before trying to initialize components during Event BeginPlay.
Create a proper loading/management system for your clients using the Game Mode class and overriding events like OnPostLogin, OnRestart Player, etc… (In the Western Multiplayer Shootout example Epic provides an example of setting this up) and replace using Event BeginPlay with your own Custom Event for initializing YourPlayerController.
Yes, I override OnPostLogin, and I have the server do something similar to what Multiplayer Shootout does in that it gets the Player Start, spawns my Character there, and has the Player Controller Possess that new Character. Right after Possess, I call an init function on the owning client with the player controller as the target, which in turns starts the setup of the Inventory in the Player Controller.
The HUD shows up correctly, but the error occurs with the PlayerInventory and I can’t pick up items.
As a note, I’m still in 4.10.
Nevermind about the delay in the OnPostLogin, it didn’t work.
If you have a proper setup in your project then you shouldn’t need a delay.
Best to try and see what is causing the PlayerInventory Null Reference in your initialize, because if the player doesn’t have an inventory it can’t pickup items
Try putting some print strings to see if your init function is finishing properly.
OK, I think I found the problem.
For starters, I checked both the Inventory Manager Component and the Player Inventory Component on my Player Controller and they both were not NULL.
Next, I decided to replicate the Player Inventory variable and initialize it with a server RPC instead of what you showed in your screenshot above.
This removed the Accessed None errors on the server.
However, I still can’t pick up anything.
I think this is because the server doesn’t know where to look when doing the line trace. I was dealing with server/client line traces in another thread. Essentially, here, when you press E, you call the Server_OnActorUsed function, which is a server RPC which will then call OnActorUsed. OnActorUsed will then call GetUsableActor, which is where the line trace happens. So in the Get Usable Actor function it uses the Character Reference and uses that reference’s Follow Camera and Camera Boom to create the two vectors needed for the line trace. However, Follow Camera and Camera Boom aren’t replicated, so the server will have no idea where to start and end the line trace. In fact, I put a Print String right after the Is Valid check on the character reference on the Is Not Valid side and it printed a string on the server, meaning the character reference is NULL.
So I think to fix this, I’m going to have to make sure that Character Reference and Equipment Character Reference are both replicated and initialized with RPCs similar to PlayerInventory. And then I’m going to need to fix the Server Line Trace to use the proper location and rotation of the cameras, which will require either setting up replicated camera variables or just passing in the start and end trace vectors through the RPC.
Awesome to see your progress OverRated_AU ! It’s cool to see all that’s possible with this system.
You were right Pirate about using the UpdateStats function to add events on item equip, that worked wonders.
I started working a bit on lootable enemy characters, and for some reason I realized I can’t loot either Tandy or Muppet anymore. I seem to be able to loot everything else ( items, skeletons and pots), just not characters for some reason. Any idea where that might come from ?
Edit : (I’m getting an error from the ‘characterreference’ node in the getusableactor, which probably is the source of the error ? )
In the Action RPG Inventory System demo player controller this is already setup to address those issues. I am not sure what is different in your project without being able to see it myself.
You said everything works fine when you play in editor with dedicated server checked, so I’m not sure why you would need to make any code changes in your project to get things to work with your projects dedicated server.
You shouldn’t need to set the PlayerInventory to replicate because of how Unreal works. The client and the server will both run the initialization code.
But since you have your own setup for initializing your player controller you need to make sure the server version is setting the PlayerInventory when it inits the InventoryManagerComponent.
If you look at the Demo init function you can see what gets called by the server/client and what gets called by the client only in this screenshot.
But none of this explains why it works normally, but not with your projects dedicated server.
Is this migrated into your own project? Muppet and Tandy are setup with the Interface to make them lootable and have the EquipmentInventoryComponent like a player has. Maybe during your migration the interface was unhooked?
It’s very similar setting up a character to be looted as any other actor like the loot containers. They just need an InventoryComponent and the Usable Actor Interface and Inventory Interface and the implementation of the interface functions.
Yes that is migrated into my own project Oh you’re right I was just forgetting to actually add the ‘inside’ of the functions, they were there but just had the base and return node for some. That’s super helpful for the lootable players.
However I’m still having an issue with those NPCS…If I switch back to both inventoryplayer and the controller instead of mine, the NPCS work, but not with my character. My character can still open pots/ skeletons and pick up items though.
In your Demo controller, you initialize via BeginPlay, which is called by both Server and Client.
I guess I can call the Initialize twice when the Client joins the server, once by Server and once by Client.
Yes, this worked. Just for a future reference for anyone who does implement the Gameplay Framework (using GameMode to control client spawning) and wants to make sure everything spawns correctly when loaded instead of using the BeginPlay with delay, the initialization needs to be called by both the server and the owning client right after Character possess in the OnPostLogin.
I am glad you got it worked out
You need to update the OnActorUsed() functions inside Muppet and NPC (Since the Tandy example is a child of NPC) and change the Cast node Cast To Inventory Player Controller to cast to your own player controller.
That’s why it works normally but not with your player controller.
Do you mean the Controller possess?