gamepad axis into player angle

Get help using Construct 2

Post » Tue Oct 09, 2012 5:16 am

hello!

I want to make my player move his arm around in 360 following the movement on the gamepad stick.

Is there a way to use the X and Y values of the axis and turn them actively into degrees from 0 to 360?
B
42
S
11
G
5
Posts: 446
Reputation: 6,417

Post » Tue Oct 09, 2012 3:38 pm

Try using an expression like this for the angle:
angle(0, 0, Gamepadbeta.Axis(0, 0), Gamepadbeta.Axis(0, 1))
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,630

Post » Tue Oct 09, 2012 6:18 pm

thanks ashley, it works perfectly =)!
B
42
S
11
G
5
Posts: 446
Reputation: 6,417

Post » Wed Jul 15, 2015 4:09 am

Is there a way to use the right axis for that? There seems to only be one gamepad.axis method...
B
5
Posts: 3
Reputation: 231

Post » Wed Jul 15, 2015 9:30 am

@menasheh: You can see in the manual article for the gamepad that the Axis(Gamepad, Index) expression expects an index value that will let it know which joystick to look for.
Likely change the second 0 to a 1 and it should read the right joystick. As mentioned, it depends on the mapping, so this is something you may have to check for before the game starts if you plan on using it.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805

Post » Wed Jul 15, 2015 3:21 pm

@Kyatric I'm using angle(0,0,Gamepad.Axis(0, 0), Gamepad.Axis(0, 1)) - this works to use the left axis. Notice the index value is different - the index value is not which joystick to use, its to choose between the X or Y axis.
B
5
Posts: 3
Reputation: 231

Post » Wed Jul 15, 2015 3:31 pm

@menasheh To do the same thing for the right stick it would be angle(0,0,Gamepad.Axis(0, 2), Gamepad.Axis(0, 3))
B
42
S
11
G
5
Posts: 446
Reputation: 6,417

Post » Sat Jul 02, 2016 8:21 am

Hello, I'm trying to make a 2 players mode using 2 gamepads. The expression angle(0, 0, Gamepadbeta.Axis(0, 0), Gamepadbeta.Axis(0, 1)) worked perfctly for the first gamepad. How can I make it work for player 2 on the second gamepad?
B
2
Posts: 1
Reputation: 152

Post » Sat Jul 02, 2016 4:20 pm

@marcellolima you can find that info in the link posted by Kyatric
https://www.scirra.com/manual/143/gamepad

There's a paragraph for multiple gamepads in one computer. Hope that helps
B
35
S
8
G
11
Posts: 398
Reputation: 8,290

Post » Fri Jul 29, 2016 3:48 am

@marcellolima That would be: angle(0, 0, Gamepad.Axis(1, 0), Gamepad.Axis(1, 1))
B
42
S
11
G
5
Posts: 446
Reputation: 6,417

Next

Return to How do I....?

Who is online

Users browsing this forum: Colludium and 26 guests