But instead of using the cursor, I want to use the joystick for it to rotate. My wand is attached to my character and I want the tip of the wand to be in the same direction where i toggle my joystick. But I’m having a super hard time figuring out how.
Hi Szeyal!
One of my projects uses a joystick aiming system, I’m not sure if it’s the same as what you have in mind but the basic concept goes like this:
If joystick is pressed up,
set weapon angle to 270
If joystick is pressed left,
set weapon angle to 180
… repeat for all remaining directions
Thing is, this method covers only 8 directions. I too have been having trouble making it cover all angles in 360 degrees when using the default joystick in gdevelop. If someone knows how to make the default joystick work in 360, be nice if they could share.
So anyway, what I did was create my own joystick setup from scratch. This new joystick can now be used to cover all angles in 360. Then apply the same concept, set weapon angle equal to the angle that the joystick is being pressed.
I’m just at my phone now, but later when I could access my project files, I’ll try to post here the relevant events.
Hi cokiesyum, I did set it equal to Joystick.StickAngle() and StickForce(), and rotating the wand works but still the tip of the wand does not match the angle of the joystick
That’s for the custom joystick so it works to aim at all angles in 360 degrees.
I use 3 objects: a hidden joystick button, a visible joystick button, and a joystickbase.
The hidden button uses the draggable behavior and can follow the finger around if it goes beyond the set boundaries of the base.
The visible button stays within the boundaries of the base and is seen on the screen as the image for the joystick button.
Note that you probably don’t need to rotate the base or anything, you could use the ‘anglebetweenpositions’ function directly for the aiming part. (I should probably change that in my project as well. lol. Though it’s probably not that big of a deal and one object angle is easier to reference, idk)
This one is the event for aiming. I’m using a crosshair (Crosshair3) in my project that’s set at a certain distance away from the character. If you’re not using a crosshair, you’ll probably only need the “rotate” part.
As mentioned earlier, here you’ll likely just need to rotate towards angle and use the function ‘anglebetweenpositions’ from the joystick.
And this is for when a keyboard is used. In case you wanted to have the keyboard as an alternative to the joystick. But as with the default joystick, it gets limited to just 8 directions.
Rotate to angle would be set as 0, 45, 90, 135, 180, 225, 270, 315, with a separate event for each direction.
So, yeah, that’s pretty much it. I hope it’s not too confusing or anything. Good luck to you.
Thank you Levio! You are amazing! I’m a beginner and had only started like 2 weeks ago hahaha, and that is a little confusing but I’ll try and learn how you did it. Thank you so much, I really appreciate this.