expressobits / inventory-system

Modular inventory system for godot 4 with nodes, compatible with multiplayer, separate logic from the UI, Using items as separate resources.
MIT License
407 stars 26 forks source link

What am I doing wrong? Item object isn't assigned to DroppedItem3D #112

Closed warsang closed 1 month ago

warsang commented 2 months ago

Hi!

I've been playing around with a multiplayer Godot example ( https://github.com/warsang/Godot-multiplayer ) and have a little tree node that when hit a bunch of times ("right_click" when close to the tree) by my character spawns a DroppedItem3d. For some reason the DroppedItem3d doesn't have an Item object assigned to it in the Godot "Remote" view.

Locally, my "WoodDroppedItem" looks like:

image

However, remotely, it looks like:

image

That means, I can't call character.character_inventory_system.pick_to_inventory(self) or I get:

image

Steps to reproduce:

I am using Godot 4.2;

  1. Clone the repo I linked;
  2. Run 1 server instance and 1 or two client instances;
  3. Click on tree a bunch of times to get it to disappear and spawn a resource
  4. Observe that the resource doesn't have an item assigned to it when it should and that calling pick_to_inventory will return false.

Thanks in advance!

scriptsengineer commented 2 months ago

The bug is a little complicated to understand, I'll have to analyze it more calmly, because it seems to me that you can instantiate the dropper without using a network?

warsang commented 2 months ago

Hmm I tried instantiating the DroppedItem3d without a multiplayerSpawner node (I was using the DroppedItemSpawner from the multiplayer example) and I get the same issue. No Item resource is assigned to the item @export of DroppedItem3d in the Remote debugger view

scriptsengineer commented 2 months ago

Hello @Warsang check here, it seems to me that the inspector just does not display the object correctly in "remote" mode, but at the top the inspector shows the ID of the item and confirms that it is complete or that, to test just click on the item marked with a arrow. image

scriptsengineer commented 2 months ago

@warsang on your example is clear that there are no problems with the inspector, but there is a bug that gives a "pick_to_inventory" and it was created for another reason, so I debug this to be able to know more.

scriptsengineer commented 1 month ago

Hello @warsang, check if the problem persists in the latest versions?

warsang commented 1 month ago

Hey! Thanks! I'll take a look; my project is using a pretty old version so it might take a while for me to update it and test. Will let you know.

warsang commented 1 month ago

Is there a working multiplayer-demo with version 1.1.2 ? My client hangs and then crashes after updating to the latest version

scriptsengineer commented 1 month ago

Can you tell me which version Godot are using?

warsang commented 1 month ago

I'm using Godot 4.2.2 stable; Since the binaries are crashing for my game project, as a path forward, I'm trying to use version 0.9.5 of the plugin which is before the C++ binaries were introduced. Hopefully that fixes my use-case but it obviously won't fix whatever crash I was hitting.

EDIT: I think I found out what the issue was? I'm still investigating to see if this fixes it; At least in 0.9.5;

I was calling a collider from my character controller and trying to interact with the node from the character controller. Basically calling:

interacted_node.interact(self)

(self here is the node that collides with the collider in my character controller; normally the dropped_item3d).

In the plugin 0.9.5 multiplayer demo, it looks like you never call interact from the character controller directly but from the interactor. As long as there's an "interact" action defined and mapped to an input in project settings, the add-on handles the picking up the item for you?

warsang commented 1 month ago

Ok I finally found out what I was doing wrong! Troubleshooting on 0.9.5 helped me find out! I had Item Max Stack set to default (0) in my inventory database. That would prevent anything from being picked up. I didn't realize max stack was a mandatory field. I'm not sure why I was seeing some crashes when I moved to 1.1.2 initially. I think I was probably missing an export or something else in my networked inventory set-up. Feel free to close the issue and thanks for the help!