Alright. Heres how it works:
First, you have to make the variables. In our case:
- Code: Select all
int BUTTONS[9];
double XAXIS;
double YAXIS;
void SetupPad() {
int i;
for (i=0;i<8;i++) {
BUTTONS[i]=GetJoystick1Button(i); }
XAXIS=GetJoystick1Axis(0);
YAXIS=GetJoystick1Axis(1);
}
This --should-- enable you to use Buttons 1-7 (Xbox style for example: A,B,X,Y,LB,RB,SELECT,START) Now, lets define some functions to use. Save that to first code to global code, name it "Setup". Now in another global code, you'd put this: (I'm using xbox 360 based controles, most common PC controls in todays games)
- Code: Select all
#define BTN_A BUTTONS[0]
#define BTN_B BUTTONS[1]
#define BTN_X BUTTONS[2]
#define BTN_Y BUTTONS[3]
#define BTN_L BUTTONS[4]
#define BTN_R BUTTONS[5]
#define BTN_SEL BUTTONS[6]
#define BTN_START BUTTONS[7]
Name this Con-Define, then save it.
Now to use this: In your actor, go to "Draw Actor" Then place this code
- Code: Select all
SetupPad();
if (BTN_A) {
//Jump here }
if (BTN_X) {
//Shoot Here }
That simple
To move the player, we'd create an offset. So go back to your Setup, and add
int offset=10000 to the code. E.G:
- Code: Select all
int OFFSET=10000;
int BUTTONS[9];
double XAXIS;
double YAXIS;
void SetupPad() {
int i;
for (i=0;i<8;i++) {
BUTTONS[i]=GetJoystick1Button(i); }
XAXIS=GetJoystick1Axis(0);
YAXIS=GetJoystick1Axis(1);
}
Now the script for moving the player:
- Code: Select all
if (XAXIS>OFFSET) {
x+=5; }
else if (XAXIS<-OFFSET) {
x-=5; }
Thats all there is to it ^^ if your confused about a part just ask