How-To: Get the right speed you want with joysticks :D
Posted: Wed Nov 24, 2010 4:13 pm
Hey guys This is a simple method of getting the right speed / velocity you want the player to move with using the controller!
First, make a text actor and call him"TEST". Then, go to draw actor and put this code in:
This will reveal the max X speed you can go with the joystick. My max results were "32768", so I open up the calculator, and type in that number, "32768" then I devide it by how much velocity I want. For example, if I want an xvelocity of "5", I'd divide it by 5.
The results:
32768 / 5 = 6553.6
So now, go to the player you want to have moving with the joystick, and put this code in (After you already put the Xaxis and Yaxis scripts in, find them here)
Use this code in the draw actor of the player or what ever actor your trying to move with the joystick
And now your player will always be moving at an xvelocity of 5
You must do the same with the yspeed
First, make a text actor and call him"TEST". Then, go to draw actor and put this code in:
- Code: Select all
float ls_XAxis = GetJoystick1Axis(0);
textNumber = ls_XAxis;
This will reveal the max X speed you can go with the joystick. My max results were "32768", so I open up the calculator, and type in that number, "32768" then I devide it by how much velocity I want. For example, if I want an xvelocity of "5", I'd divide it by 5.
The results:
32768 / 5 = 6553.6
So now, go to the player you want to have moving with the joystick, and put this code in (After you already put the Xaxis and Yaxis scripts in, find them here)
Use this code in the draw actor of the player or what ever actor your trying to move with the joystick
- Code: Select all
xvelocity = ls_XAxis / 6553.6
And now your player will always be moving at an xvelocity of 5
You must do the same with the yspeed