Help Understanding What I Just Did (Analog Controls)

  • I am making a dual-analog shooter, and I just implemented the gamepad controls. They work great, but because I got part of the solution from a tutorial, I don't quite understand exactly what it does. I'm working on the game with a student, so it's important that I understand how it's working so I can explain it to him.

    The left stick controls the ship movement and the right stick controls its orientation. Where I'm confused is what the three pairs of numbers are referring to in the first action in the right analog-stick event, here: "angle(0,0,Gamepad.Axis(0,2),Gamepad.Axis(0,3))". Can anyone break this down in a semi easy-to-comprehend way, please? Thanks!

  • From the manual :

    Gamepad expressions

    Axis(Gamepad, Index)

    Retrieve the current position of an analog joystick on a specific gamepad. Index specifies left analog X and Y or right analog X and Y axes, subject to Key mapping. Axes range from -100 to 100. Axis values within the Analog deadzone are returned as 0.

    o I believe the that axis index 2 and 3 means X and Y axes of right stick if you use basic mappings.

  • Thanks, Magistross. Yes, I am using the basic mappings. I still have a few questions about this though.

    What is the first 0,0 referring to?

    What is the 0 in (0,2) and (0,3) referring to?

  • It's the gamepad index, 0 being the first gamepad. Unless you have multiple gamepads, you should always use index 0.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • So every instance of 0 before a comma is telling it that this refers to gamepad 0, correct?

    What about the second 0 in 0,0? What's that doing?

    And thanks again for the help, I really appreciate it.

  • First, there is the angle(x1,y1,x2,y2) which gives the angle between the two points provided. Second, there are two Gamepad.Axis(gamepadIndex,axisIndex) which return the displacement of each axis. The angle() function is used with (0,0) as first point, and gamepad axes displacement as second. In a whole, the expression gives you the angle formed by the right analog stick.

  • Ok, I think I got it, or at least enough to explain the concept. That was a little more complicated than I was expecting -- certainly the most complicated thing we've encountered thus far.

    Just out of curiousity, is there a less-involved way that we could have accomplished this right analog stick action?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)