User Tag List

Results 1 to 10 of 10

Thread: Analogue Stick Directions

  1. #1
    Clicker Multimedia Fusion 2iOS Export ModuleXNA Export Module
    Asholay's Avatar
    Join Date
    Nov 2008
    Location
    England
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Analogue Stick Directions

    Hi peeps - is there an easy way to get the direction from an analogue stick? At present the only values you can obtain are the horizontal and vertical position and unfortunately my maths is a bit sketchy these days

    I'm just testing things at the moment and am trying to get a turret to always look in the direction of the right stick.

  2. #2
    Clicker Multimedia Fusion 2

    Join Date
    Aug 2009
    Location
    Finland
    Posts
    39
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't claim to know how to best go about this, and I don't have the XNA exporter yet, but...

    Cos and Sin would probably be the way to go math wise, but you can do the same with Advanced Direction Object, and have the angle of the turret set to Direction Between Two Points, giving the first point X=0,Y=0 and the second point the horizontal and vertical positions you got from the gamepad.

    The above is assuming the analog stick has 0,0 for center point, but if not, then you need to figure out what the X and Y of the center are and use those for the first point. When using the Joypad object, the center point seemed to be max_value/2 for both axises, as the top-left corner of an analog stick of an X360 gamepad (on a PC anyways) gives roughly a position of 0,0 and the bottom right is something around 65500,65500 or something. Joypad was able to fetch the max values, I think.

    Don't quote me on any of that though. It's just how I think it was. ;P

  3. #3
    Clicker Multimedia Fusion 2iOS Export ModuleXNA Export Module
    Asholay's Avatar
    Join Date
    Nov 2008
    Location
    England
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks V - the Xbox sticks returns 0,0 for dead centre and -/+100 for maximum directional push.

    I've got to be honest, I was expecting there to be an expression for directional value!


    Edit - just noticed the Direction Calculator object has a convert XY into direction - this can be combined with the X & Y positions of the sticks to successfully work. Thanks for the tip in the right direction.

  4. #4
    Clicker

    Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export Module
    geothefaust's Avatar
    Join Date
    Jul 2006
    Location
    Portland, OR
    Posts
    498
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Glad you got it figured out. It's really just basic maths when you look at it. I didn't have any trouble setting it up when I was testing it. The dir calc works too of course.

  5. #5
    Clicker Multimedia Fusion 2iOS Export ModuleXNA Export Module
    Asholay's Avatar
    Join Date
    Nov 2008
    Location
    England
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What method do you use? I'd far sooner use the correct maths than an extension as it'll be better on mem and space.

  6. #6
    Clicker Multimedia Fusion 2 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleMac Export Module
    colej_uk's Avatar
    Join Date
    Nov 2006
    Location
    UK
    Posts
    739
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I used this method with a recent shooter game I am working on:

    ATan2((StickRightV*-1.0), StickRightH)
    Converts the axis values to an angle.

  7. #7
    Clicker Multimedia Fusion 2iOS Export ModuleXNA Export Module
    Asholay's Avatar
    Join Date
    Nov 2008
    Location
    England
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's exactly the sort of thing I was looking for thanks, but I can't quite get it to work for me - it just spins around with any input given. I'm avoiding the trig, but something tells me I need to get some books out again :S

  8. #8
    Clicker Fusion 2.5 DeveloperFusion 2.5 DeveloperAndroid Export ModuleiOS Export ModuleXNA Export Module
    DistantJ's Avatar
    Join Date
    Jan 2008
    Location
    Gloucester, UK
    Posts
    2,142
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    It's not tough, just remember your SOH CAH TOA, get working out some angles on some Triangles...

    This guy's videos help a lot:

    http://www.youtube.com/watch?v=F21S9Wpi0y8

  9. #9
    Clicker Multimedia Fusion 2iOS Export ModuleXNA Export Module
    Asholay's Avatar
    Join Date
    Nov 2008
    Location
    England
    Posts
    360
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, done some more testing with counters watching everything and ColeJs method does work perfectly - but for some reason, the horizontal and vertical values returned by the gamepads is a bit touch and go?

    Pressing forward goes from 0 to -100 perfectly, but pulling down works it's way towards +100, then when it hits +100, it provides a -100 reading instead??

    Does that happen for you guys as well?


    Edit: only seems to do it when testing through Windows, works ok on xbox... bah, there's so many slight differences between running on win & box!

  10. #10
    Clicker Fusion 2.5 (Steam)

    Join Date
    Feb 2015
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi. How exactly do i convert an X,Y value into an angle? If you could help it would be greatly appreciated.

Similar Threads

  1. Ouya analogue stick example?
    By DedHedZed in forum Android Export Module Version 2.0
    Replies: 5
    Last Post: 14th July 2013, 11:13 AM
  2. Mmf2 on Usb Stick
    By iamjot in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 13th December 2012, 08:38 PM
  3. How to detect d-pad instead of just analogue stick on x-box controller with joystick2
    By BrashMonkey in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 20th October 2012, 10:18 PM
  4. Stick to object bug
    By Evilized79 in forum iOS Export Module Version 2.0
    Replies: 0
    Last Post: 1st February 2012, 05:31 PM
  5. Customisable Analogue Clock
    By Raylax in forum File Archive
    Replies: 5
    Last Post: 13th November 2008, 04:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •