360 controller

Get help using Construct 2

Post » Fri Aug 09, 2013 10:26 pm

i am trying to make an over the top shooter game, similar to geometry wars, using the xbox controller. i have tried a few different things like:
left analog X axis > 0 then move right
and the same for up left and down, this works great, the character moves in the correct directions.

but now i tried the same thing with looking,
gamepad right analog x axis rotate 90 degrees and toward 0
90 for up, 180 for left, and 270 for down. then went to even say,

If right xaxis > 0 AND right yaxis > 0, then rotate 90 toward 45 degrees.

unfortunately, some of these work, and some do not. and i only think some work because up down left and right worked just fine, but the character sometimes starts looking at a 45 degree angle... im just wondering if theres an easier way for xbox controls? its taken 12 code bunches just to use the move and aiming and its not close to perfected.

picture of my broken coding
http://imgur.com/i85VDb9
B
5
Posts: 33
Reputation: 316

Post » Sat Aug 10, 2013 12:25 am

The problem is that you're rotating the object like that, probably to have a "smooth" feeling to the rotation, right? You should just set the angle degree directly to what you want using "Set Angle" instead of "rotate to angle".

And to make diagonals works, you gotta check if it's between 0 and 50, I think. For instance, when you press up on the analog, the Y goes to -100 and X is 0, but if you press it UP + RIGHT, the Y is -50 and the X is 50.

If you press it to the right, Y is 0 and X is 100.

Probably you could translate these numbers directly to angles, but I wouldn't know how to do that..
B
124
S
43
G
41
Posts: 849
Reputation: 28,235

Post » Sat Aug 10, 2013 12:41 am

This question came up earlier today, and I answered it already, but here's an example capx that includes movement controls.

It's pretty rough, but it functions well enough.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Sat Aug 10, 2013 4:18 am

you can use the angle the stick is at to move things around

angle(0,0,Gamepad.Axis(0,0),Gamepad.Axis(0,1))

after this you just need to add a "move forward" action when "something"
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Post » Sun Aug 11, 2013 5:15 am

im gunna be honest and say i have no idea what a (0,1) would even represent. 0 no and 1 for yes? meaning if it being moved? please describe a bit more.
B
5
Posts: 33
Reputation: 316

Post » Sun Aug 11, 2013 5:28 am

Thanks Geo, that looks awesome, im going to try it out now
B
5
Posts: 33
Reputation: 316

Post » Sun Aug 11, 2013 5:39 am

@sxespanky The manual and tutorials will teach you what the different numbers are.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,583

Post » Sun Aug 11, 2013 7:45 am

So i've tried Both Geometrix, and sargas, your methods, but when i go to look, now its stuck at - Looking at the top left area, indefinitely, moving the stick around it will try and look about 1-2 degrees differently, but thats it. ill go find the controller tutorial, wherever this may be.
B
5
Posts: 33
Reputation: 316

Post » Sun Aug 11, 2013 10:18 am

Actually, oddly enough, there is no tutorial for using the gamepad object. The manual entry, however, does explain exactly what the 0 and 1 means. If you're not willing to do at least a modicum of research on your own, then you're going to have a lot more trouble than just getting gamepad movement to work.
B
57
S
15
G
11
Posts: 912
Reputation: 12,606

Post » Sun Aug 11, 2013 6:37 pm

@sxespanky

Gamepad mapped

i think you'll should get what you need from that. ( I actually made that capx originally to test how messed up were the sticks on my controller xD)
B
43
S
12
G
6
Posts: 446
Reputation: 6,802

Next

Return to How do I....?

Who is online

Users browsing this forum: BackendFreak, kalibark2, Mohicano and 33 guests