The Daily Click ::. Forums ::. Klik Coding Help ::. Analog Joystick Control (mmf)
 

Post Reply  Post Oekaki 
 

Posted By Message

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
18th August, 2006 at 13:23:58 -

I have an analog gamepad and i want to use the joysticks for two seperate controls. i want to use the left stick for direction and the right for firing. i need 360 movement but i cannot find the right extension to do it.

I have used the built in analog control extension and also AGCO (crashes mmf), ControlX, Control Interpeter and Joypad object. none of these give the required result. the closest i have come is making the object i want to control jump around like mad. please help and you will get a mention in the credits of my game.

 
n/a

Fifth

Quadruped

Registered
  07/05/2003
Points
  5818

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
18th August, 2006 at 13:35:52 -

I think the Joypad Object should be able to do what you're requiring.
You just have to realize that the analog scale is from 0 to 65280 (I think) on each axis, with 32512 being the neutral center.

 
Go Moon!

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
18th August, 2006 at 13:41:43 -

thanks for the quick reply. i havent a clue how to use this data though. i have only just thought of using analog controls for the game. please help this is all new to me.

 
n/a

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
18th August, 2006 at 13:55:05 -

There is an "analog joystick" extension for MMF2 - I don't know if there is one for MMF though.

 
This is a signature. Have this one on me.

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
18th August, 2006 at 13:57:40 -

there is one built into mmf but it is crap. the only things i can get out of it are raw values for X Y Z and buttons A B C D. this does not help me much!

 
n/a

Fifth

Quadruped

Registered
  07/05/2003
Points
  5818

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
18th August, 2006 at 15:03:56 -

Well, using the Joypad Object, you should be able to get the raw values for six different axes. For a standard PS2 controller, the X and Y axes for the left analog stick are simply X and Y, while those for the right analog stick are Z and R.

You say you want 360 degree movement from this? You should be able to just use the Direction Calculator (or Advanced Direction Object, I think it's called now?) to convert these raw values into a 360-degree direction and a speed value.

It'll look something like this...

Find the angle with:
Direction( "Advanced Direction Object", 32512, 32512, RawX( "Joypad object", 0 ), RawY( "Joypad object", 0 ) )

And find the speed with:
LongDist( "Advanced Direction Object", 32512, 32512, RawX( "Joypad object", 0 ), RawY( "Joypad object", 0 ) )

'Course, the problem that arises then is that the distance values can get too great to calculate, so I'd suggest you scale it down with something like this:

LongDist( "Advanced Direction Object", 1016, 1016, RawX( "Joypad object", 0 ) / 32, RawY( "Joypad object", 0 ) / 32 )

And for the right analog stick, just replace the RawX and RawY with RawZ and RawR.
I hope that all made sense...

 
Go Moon!

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
18th August, 2006 at 18:25:10 -

thanks for the help fifth but this is really winding me up now. the code you gave me develops a syntax error so i tried to edit it a little and all i got was jumpy turning again. i'm not bothered about the speed i just need 360 degree turning for now the speed is controlled on a trigger button so that is easy enough to do. can somebody fix this for me or at least create an example for me to edit.

EDIT: Tried the code you gave me again fifth and it was valid this time (?) but it still gives me erratic turning.


Image Edited by the Author.

 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
19th August, 2006 at 18:37:59 -

sorry to bump this thread but i am reaaly frustrated by this problem. can anbody please help?


 
n/a

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
20th August, 2006 at 20:00:38 -

ok finally fixed the control system up just one more slight problem. when i stop moving the object it reverts back to it's starting direction instead of the direction it was last moving. can anybody tell me why?

 
n/a

Fifth

Quadruped

Registered
  07/05/2003
Points
  5818

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
21st August, 2006 at 16:39:33 -

Hmm, I think that'd be because it can't calculate the direction properly when the analog stick is so close to the center.
I'd suggest setting a separate value to the analog stick's distance, and then only adjust your angle when that distance value is greater than some number.

 
Go Moon!

lembi2001



Registered
  01/04/2005
Points
  608

VIP MemberIt's-a me, Mario!Wii OwnerI like Aliens!Has Donated, Thank You!PS3 OwnerI am an April Fool
21st August, 2006 at 18:03:02 -

Thanks for the tip but i've realised that it isn't musch of a problem now as you shouldnever be still during the game. keep your eye out for the demo coming soon.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click