Help! Standard inventory problem. ddabrahim Please help

How do I…

I’m trying to add the main player’s inventory to my game.

What is the expected result.

I’m using the standard inventory from the examples.

What is the actual result

When I change the camera zoom by 2x, when moving items inside the inventory, the actual location of the mouse cursor and the actual location of the dragged item differ by 2x, exactly by how much the camera zoom was applied.

Appropriate screenshots

Attached.

**Question. I understand the reason but I don’t understand how to fix it.

I realize that I need to somehow get the pointer_dragobject position and multiply by 2.

I have not tried to do this, but I have not been able to do it.

The inventory slots and pointer object are located on their own layer called “inventory”. Can you apply 2x zoom on the inventory layer too? It should solve the problem.

Otherwise if you need to keep the zoom on the inventory 1x yes you need to do the math to take in to account the slots and pointer object in the inventory slots are on separate layers and the camera on the inventory layer has default 1x zoom.

Okay I have also realised, in the Inventory example when I position the pointer object to the mouse, I forgot to take in to account the possibility the camera on the base layer may going to move. So if you move the camera, it is possible the camera zoom got nothing to do with the problem you are experiencing, but I have positiond the pointer object on the mouse relative to base layer.

So what you need to do is change the expression from this:
MouseX(“”,0) MouseY(“”,0)

To this:
MouseX(“inventory”,0) MouseY(“inventory”,0)

To position the pointer object relative to the mouse on the “inventory” layer.
It should solve the problem and you don’t need to zoom the camera on the inventory layer like I was suggesting earlier.

Let me know if it worked.

Thank you for responding so quickly.

  1. you can look at this template yourself, it’s called inventory system
  2. I added everything as you wrote, but I get an error, although I know for sure that such a layer exists.

I think that it is at the moment of animation, you need to specify the correct object position variables

Yes I have created a new project with the inventory example so it should be up to date.

On my side it has the inventory layer and the event I was talking about should be located at the bottom of the “Initialise inventory” event group.

Actually, here is the JSON have a look and see if this is what you after:

Dear ddabrahim. I realize that I can take up your time and ask stupid questions.

But this is the second problem I have encountered with gdevelop.io.

How to import the code you sent me. I’ve seen videos on how to save a project, but I don’t know how to upload my code.

I didn’t manage to transfer the inventory to my game, so I took a standard example of inventory and started to transfer my game and all its mechanics there. Do you have any idea how ridiculous that sounds?

If you show me how to upload this file on gdevelop.io. I will be very grateful.

Thanks, I figured out why I couldn’t get that code to paste, I had to replace the upper quotation marks.

It’s working now.
I want to make my game so badly and I have success, but when you don’t understand what the problem is you get down.

Thank you for the answer.
Anyway tell me how to upload projects if possible.

if you are using the browser version of GDevelop, it is possible you need to clear your cache and reload your project to see changes take effect.

I don’t personally use the browser version but it seems to me you need to extract the project from the zip, upload the folder to your Google Drive and you can import the project from your Google Drive.

After you have extracted the project folder from the zip, to open it just go build->Open a project next to the “+ Create a project” button

In the web version then select Google Drive and then your project.
In the desktop version select the project folder wherever it is on your computer.

It should be pretty straight forward really.

1 Like

Yay now my game will probably have an inventory now, here’s what I have already.

When I’m done I’ll charmingly share a free key with you.

1 Like

I like the atmosphere, looks interesting.
If you have any further problems with the inventory example let me know, it was just a quick, dirty experiment 5 years ago so I would imagine there are tons of things I didn’t consider when I made it.

Good luck :+1:

I knew you were making it.
What do you have to do with gdevelop.io?

Let me tell you something.

  1. the icons for the test scenes are very lacking. I could help to make them for free so that people understand what it is about, because it is much easier to search visually.
  2. Immediately after you helped me solve this problem I moved on. I would like the inventory can be dragged in space and again I have a stupor, how to implement this, because there are so many logical variables in dragging items inside the backpack. What to say about the full inventory.
  3. I think that there will be no problem that objects are automatically added to the backpack when the player bumps into an object.
  4. Of course the character’s backpack is great, but how about a backpack at the enemy and the ability to search it.
  5. I would also very much like to be able to display a small information window when pointing at the object where there will be a description of what the object and why it is needed, as well as its characteristics.

I like to work with this mechanism, but the examples are not enough to realize more or less a game in an interesting mechanics.

I’m willing to pay if you can help me implement some mechanics in this game. I’m a designer with a lot of experience, but it’s quite difficult for me to understand even visual coding.

You can leave me your personal contacts and we can try to work of course if you are interested.

I am not a member of the dev team, I have only contributed with some examples years ago to help beginners but I have 0 control over how things are done with the website and the software or even the examples. Now that they have included the examples it is up to the dev team what they want to do with them. I have 0 control.

It can be easily done. Just make the background draggable and update the position of the slots every frame to stay in place.

I think you can just replace the mouse click event with a collision check and it should work. So instead of checking if the mouse was clicked, you check if the player did collide with it.

It can be done easily I would think using just some object variables, each enemy would have one or more random items stored in variables and display them when clicked. Then same logic apply if we click item, we put it in to inventory.

I think it would require only an additional variable to store a short description we can display when mouse is hover over or something.

If you can send me a link to your project in DM, maybe I can help you to implement some mechanics. I have some free time in the next couple days.

1 Like

I didn’t even expect such a detailed response. I appreciate it, you really know what you’re talking about.

I will definitely write to you and send you the project.