Gamepad rotate and move

  • Hi guys,

    I'm using the gamepad. Any idea how to set it up so that a sprite will rotate so that it is pointing in the direction of the right stick, and moving based on the left stick.

    Tried searching and the manuals, but it's a little tricky.

    Any help would be appreciated.

  • THis may be what you are looking for... Analog Stick Trouble

  • Hmm, not having much luck with that. Also, is it right that I have to push a button on the controller before the rotating even begins?

    Surely there's an easier way to do this.

    Rotate sprite angle to gamepad right analogue stick angle.

    Wha?

  • one action is about as easy as it get's.

    Right stick angle is angle(0, 0, Gamepad.Axis(0, 2), Gamepad.Axis(0, 3))

    Also as for your other question in regards to requiring a button press. yes, this is a browser problem. The browser will not enumerate/acknowledge the controllers until any button is pressed. The best way around it. is to use a front screen.

  • jayderyu

    I can't get this working with the rotate to command. Do you mind having a look at the example I put above (I stupidly highlighted as "Wha?")

  • Try changing where you have rotate angle to just set angle - this will set your sprite facing the direction you are pressing

    edit to add file:

    but found out I cant post links yet - sorry.

  • RamPackWobble

    Thanks, I noted that when I have is as set to it worked fine, but it's not the effect I want. I'd like the sprite to be able to rotate toward the direction of the stick, rather than just pop in the certain direction. Maybe I could try lerping if that's not working for me.

  • try -

    -----------------------------------------------

    set up a global variable "AngleRequired" (number)

    every tick

    system - set AngleRequired to angle(0,0 gamepad.Axis(0,2), GamePad.Axis(0,3)

    sprite rotate 1 degrees toeards AngleRequired

    -----------------------------------------

    you will also need to set up a dead zone on your joystick or it will turn towards 0 degrees all the time when not pushed.

    dl.dropbox.com/u/143636437/temp/RotateGamepad.capx

  • Isn't there some math fun you can do as well to make sure it rotates in the direction that the stick is closest to, for example you want it to rotate the 30 degrees to the place the stick is pointing as opposed to rotating the other direction 330 degrees to get there...

  • ...or even the further you push the joystick the faster you turn ...?

  • RamPackWobble

    It's nearly there, but for some reason the main 90 degree angles (up, down, left and right) have a dead zone to them of around 15 degrees. I also can't figure out how to sort it out so the number doesn't change when you don't move the stick.

    I guess this behaviour still needs some tweaking?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • to fix the don't change direction when the stick is centered could you put in a condition that where you check if the stick is being held before the point in this direction :

    something like...

    is gamepad>joystickRight X or Y position greaterthan abs(50)

       then

       turn player towards the same direction

  • Also, to fix the first issue, using RawAxis creates a better result. Looks like this could potentially sort things out for me, but it's a little more complicated than I expected.

    C2 is obviously spoiling me <img src="smileys/smiley2.gif" border="0" align="middle" />

  • Have I got it right that

    Gamepad.RawAxis(0,0)

    should return a value from -100 to 100 depending where I have the leftstick x position ?

    all I get is -1>nothing>1

    see :

    dl.dropbox.com/u/143636437/temp/joytest.capx

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