Inventory control: from mouse to controller

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Orkimede

Hello everyone,

i followed this tutorial to create an in-game inventory, Diablo style:

Everything works perfectly, and except few adjust i made so the object are usefull, i basically copy pasted the code. I added it in the zip file. Feel free to take a look, or simply grab it for yourself.

My problem: i don’t manage to use a controller to use this inventory.

What i did: I modified the main code so the cursor doesn’t react to the mouse position but to be piloted by the right game joystick.

What happen: beside the fact that i had to modify the code so the modified cursor returned a global position, when i let go of an object, it is stuck in place, without taking care of the structure working with the mouse. Even wort: i can’t move the thing at all at this point.

The modification is the following

    func _process(delta):
         var xAxisRL = Input.get_joy_axis(0, JOY_AXIS_2)
         var yAxisUD = Input.get_joy_axis(0 ,JOY_AXIS_3)
         var JOYPAD_SENSITIVITY = 20
         $CurseurManette.position += Vector2(xAxisRL,yAxisUD) * 20
         var cursor_pos = $CurseurManette.position + self.rect_position +   get_node("../").position

replacing:

    func _process(delta):
           var cursor_pos = get_global_mouse_position()

I will keep looking on my side, but i figured getting an external POV might help.
Sheer, and thank for your time!

Orkimede