3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1] 2

Author Topic: Joystic/gamepad control  (Read 1196 times)

« on: August 05, 2013, 01:35:13 PM »
Hi.

I want add Joystic/gamepad control into my game.I see JOYSTICK/GAMEPAD/STEERING-WHEEL FUNCTIONS in Script Reference but I can't work with thems.can anyone tell me how can move car or any character with Gamepad?

Thanks
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #1 on: August 05, 2013, 02:31:58 PM »
For Joystick steering add script linked to PCar...

OUT_x =  iJoyX(joysticknumber);

where...
joystick number is zero for the first stick, one for the second etc
OUT_x is the Steering(-1,1) (PCar) output
The joystick returns values from -1 to 1 across the range of movement, so ideal for PCar, character is more complex but if you understand the above the principles are the same and a little applied logic will get you where you need to be

(This can be refined to find true centres of joysticks/smooth the movement etc)
« Last Edit: August 05, 2013, 02:37:06 PM by Cypermethrin »
« Reply #2 on: August 07, 2013, 10:20:21 AM »
Quote
For Joystick steering add script linked to PCar...

OUT_x =  iJoyX(joysticknumber);

where...
joystick number is zero for the first stick, one for the second etc
OUT_x is the Steering(-1,1) (PCar) output
The joystick returns values from -1 to 1 across the range of movement, so ideal for PCar, character is more complex but if you understand the above the principles are the same and a little applied logic will get you where you need to be

(This can be refined to find true centres of joysticks/smooth the movement etc)

Thanks.

I can understand, But I don't know what is joysticknumber? how can define bottoms for custom action?(e.g how define arrow key in joystick?)
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #3 on: August 07, 2013, 01:24:02 PM »
I can understand

No, I'm afraid you don't, stick to keys
« Reply #4 on: August 08, 2013, 12:56:07 PM »
I can write this script But I Need understand Two things:
1 - I Need Know more Explanation about joysticknumber?
2 - I want Know can use joystick button number According to this Picture? and what is  (0-127) in iJoyButtonDown Function?

I want to write my own script and just need you to help me.

Thanks A LOT
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #5 on: August 08, 2013, 02:08:24 PM »
Joystick Number is Joystick 1(left) or Joystick Number 2(Right), Right?
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #6 on: August 08, 2013, 02:13:08 PM »
For Joystick steering add script linked to PCar...

OUT_x =  iJoyX(joysticknumber);

where...
joystick number is zero for the first stick, one for the second etc
OUT_x is the Steering(-1,1) (PCar) output
The joystick returns values from -1 to 1 across the range of movement, so ideal for PCar, character is more complex but if you understand the above the principles are the same and a little applied logic will get you where you need to be

(This can be refined to find true centres of joysticks/smooth the movement etc)

Write a script that displays each button number status and press the buttons...then you'll find out what button is what number, or just define anything and use the "configure controls" object
« Reply #7 on: August 09, 2013, 01:33:43 PM »
I wrote this script for print Pressed key, But only Print one key.Where is Problem?

I can Find some Key numbers but can't find Joystick arrow key numbers.

Code: [Select]
int JoyBtnNum;

void Main()
{

  bool JoyBottonDown = iJoyButtonDown(0,JoyBtnNum);
  if (JoyBottonDown) iPrint("Pressed BTN is: "+JoyBtnNum,-15,5,OBJ_22);
}
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #8 on: August 09, 2013, 02:40:08 PM »
Where is Problem?

int JoyBtnNum;   
// means - declares JoyBtnNum as an integer - defaults to 0 as no number specified

void Main()
{

  bool JoyBottonDown = iJoyButtonDown(0,JoyBtnNum);   
// means - joyBottonDown becomes true if button 0 pressed

  if (JoyBottonDown) iPrint("Pressed BTN is: "+JoyBtnNum,-15,5,OBJ_22);

// means - if button 0 pressed print JoyBtnNum - which is always 0
}


all this will do is print 0 when you press button 0

There are no joystick arrow keys, you use the iJoyX & iJoyY commands for stick motion as already shown in my first post.

Sorry, I did try to help but I've just lost patience....maybe someone else will step in and help but I'm out.
I think you need to start at a much more basic level of learning logic and how angelscript and Rad works.
Best of luck though
« Reply #9 on: August 09, 2013, 03:31:27 PM »
I think a way around this is not to determine what the joypad numbers are, but to make your own!

For example, if you pressed down, make another variable that says when that particular button is pressed to give it a value of, say 1.  Then when you press up give that a value of 2 and so on.  Then you can use if statements to say if your variable is 1 to do down arrow stuff, when its 2 do up arrow stuff, etc.

Hope this helps or even works!

-Sorv
« Reply #10 on: August 10, 2013, 01:07:33 AM »
Thanks Cypermethrinو You helped me a lot.
« Last Edit: August 10, 2013, 05:41:47 AM by behdadsoft »
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #11 on: August 10, 2013, 10:16:50 AM »
I could use iJoyBottonDown(int,int), But I can't use iJoyX(int) Function.
I Used OUT_X = iJoyX(int) but I can't steering the car wheels.I think Joystick Arrow Keys must have a number for write script.

Please Guide ME.
« Last Edit: August 10, 2013, 01:03:36 PM by behdadsoft »
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #12 on: August 10, 2013, 08:36:30 PM »
Whenever I want to know if my input is working correctly i make a dummy variable and set it to 0 in the if (iInitiailzing()) part, then in the if statment for a button press, mouse click, or in your case joystick, i make the dummy variable equal a value that is linked to a Value Print object.  This ensures that I know the input is working properly and sets up a system I may need for later for multiple inputs as well as a custom controls menu.

-Sorv
« Reply #13 on: August 11, 2013, 08:45:01 AM »
this is not art related and does not belong in the ARTIST'S DISCUSSION FORUM...

--Mike
« Reply #14 on: August 11, 2013, 11:49:01 AM »
Quote
this is not art related and does not belong in the ARTIST'S DISCUSSION FORUM

WHAT?

ok, Mike.

I wrote this script for move the car, But it's not good working. can you help me?

Code: [Select]
void Main()
{
   if (iJoyButtonDown(0,2))
   {
      OUT_1 = 1;//throttle
}

   if (!iJoyButtonDown(0,2))
   {
      OUT_1 = 0;//throttle
}
}

and I can't find good example or post that could steering the wheels with joystick. can you help hemo to solve this two problems?

Thanks Mike
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
Pages: [1] 2