Devlog #5 - Item Dropping & Inventory


Last Week:

After having a small struggle with this last week I was preparing for this to take a while, and I was not wrong. This was defiantly the mechanic that took the longest to move to Netcode. Thankfully, I was using an agile-like approach to this project so it was really easy for me to adapt the plan to accommodate for this. 


Solving the Problem:

Last week I pinned down the issue of the item dropping to be that you cannot spawn an item if you are not the host/server, I knew that to solve this I would need to make use of ServerRPCs. This is a request that the clients can send to the server to run code on the server. I have used these before but I didn't really understand specifically how to implement them. Naively, I thought that I would be able to stumble my way through them and not have to do a deep dive into how to use them to spawn an item. This was a huge mistake, I have been very careful with learning the process in depth and implementing it once I have learned about the system. This led to a 3 day long nightmare of not really understanding the system that I am trying to implement. Eventually, I was able to come up with a solution of sending the unique ID of the prefab that I am wanting to spawn, this is to get around the RPCs being unable to send complex data types (GameObjects, Class, ect). The way that I get this unique ID to be the same on all clients is to calculate them when the Network is started and saving that and sending it to all clients that join, these clients just need to lookup that ID for the item they would like to spawn and send that through the RPC for the server to spawn. Not the best solution but it does work.


Lesson:

In the future I will be planning and thinking more strategically about the systems I'm making and ensure that I understand them before I add them, avoiding a situation like this and increasing my actual learning behind this project.

Get Candy Corporate

Download NowName your own price

Leave a comment

Log in with itch.io to leave a comment.