How do I move the object exactly at angle of analog stick?

Get help using Construct 2

Post » Thu Feb 18, 2016 1:05 am

Olgoth wrote:Hi Megatronx, Is something like this what you are looking for?

Code: Select all
https://www.dropbox.com/s/qf88r9zb2bfwn24/mouse_sustitution.capx?dl=0


Basically you create a second "mouse", if the real mouse is still visible I guess you could make "at the start of layout" > mouse > Set cursor style > none.

That way the mouse would be invisible when it overlaps the game window.
I hope it helps.


No. I have that already. What I'm after is moving the object at exact angle of the angle of right analog stick. So if I press the stick at 78 degrees, that will be the angle the object moves.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
78
S
21
G
19
Posts: 1,932
Reputation: 17,316

Post » Thu Feb 18, 2016 1:14 am

megatronx wrote:Any clue what index right stick axes are?


I haven't used this object myself yet, but you could test this pretty quickly. I've made a capx for you. I hope it works, I can't check myself as I don't have a gamepad hooked up.

https://www.dropbox.com/s/8pes8gkyav87f ... .capx?dl=0

The reason it probably isn't specified is because there are many different gamepads out there, each with different amounts of input axes/mappings.
Mistakes were made.
B
47
S
23
G
107
Posts: 1,571
Reputation: 60,133

Post » Thu Feb 18, 2016 1:22 am

oosyrag wrote:
megatronx wrote:Any clue what index right stick axes are?


I haven't used this object myself yet, but you could test this pretty quickly. I've made a capx for you. I hope it works, I can't check myself as I don't have a gamepad hooked up.

https://www.dropbox.com/s/8pes8gkyav87f ... .capx?dl=0

The reason it probably isn't specified is because there are many different gamepads out there, each with different amounts of input axes/mappings.


Thx, but don't have installed latest beta.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
78
S
21
G
19
Posts: 1,932
Reputation: 17,316

Post » Thu Feb 18, 2016 3:35 am

Probably to get the angle of the right stick it would be:
angle(0,0,gampad.axis(0,2),gamepad.axis(0,3))
B
89
S
30
G
95
Posts: 5,160
Reputation: 63,456

Post » Thu Feb 18, 2016 8:34 am

Get the input for both the horizontal and vertical axes of the stick you want.

angle = arcTan( stickY/stickX )

moveVector( cos(angle), sin(angle) )

Do whatever to make the code work. Using the arctangent from the stick data will get you the true angle, and using cosine and sine as the X/Y movement increments will ensure it moves in the correct direction. Increment at whatever units you're using.

Hopefully that helps.
B
2
Posts: 1
Reputation: 152

Post » Thu Feb 18, 2016 1:00 pm

R0J0hound wrote:Probably to get the angle of the right stick it would be:
angle(0,0,gampad.axis(0,2),gamepad.axis(0,3))


YES!!! Thanks!!! Brilliant!!!
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
78
S
21
G
19
Posts: 1,932
Reputation: 17,316

Previous

Return to How do I....?

Who is online

Users browsing this forum: emreyigit03, plinkie and 4 guests