Aiming With The Right Stick In TDS (Gamepad Extension)

Hello!

I’m making a Top Down Shooter and I’d like to implement gamepad controls. I do have the Gamepad extension installed and I have successfully gotten the left stick to move the player around. The problem is I’m not having any luck getting the right stick to aim the gun (I have the gun “pinned” to the player). I have used the expression builder to see what options are available, but I don’t quite understanding how to use those options. I would greatly appreciate if someone could walk me through the steps to get this to work!

Please note, I do not wish to include the virtual joystick extension as I don’t want touch controls in the game.

How do you want the aiming to work? Rotate in place?

How are you pinning the gun to the player? A screen shot of the events would be useful.

I want it to work by aiming the gun at a fixed point, in the direction/rotation that the stick is moved. I’ve pinned the gun to the player using an origin point. I will share screenshots of what I have now (using mouse position) as well as the solution that was used as an example in Construct 3. The Construct 3 example might be helpful to someone like you, who is more experienced with GDevelop than I am. :slight_smile:

These are my events:

These are screenshots of the Construct 3 example:

The Global Variables for the sticks:

The condition and action:

The Evaluate Expression condition and value:

The Set Value action:

The Set Angle action:

I hope this helps you help me!

Hi there,

I use the following code to aim with the right stick, and indeed you will need to have the controller extension installed.

Rotate Player1 towards Gamepads::StickRotationValue(1, "Right") at speed 300 deg/second

I recommend you set the angle of the gun to the angle of your Player1, both need to have the same default angle in that case.

Hope it helps for you