gamepad_axis_value(device, axisIndex);
Argument | Description |
---|---|
device | Which gamepad device "slot" to check. |
axisIndex | The axis index to check (see the constants list). |
Returns: real
You can use this function to get the value of the different axes
from a given gamepad. The return value will be between -1 and 1 for
each of the available horizontal and vertical axes (the constants
used by this function can be found listed here).
var haxis = gamepad_axis_value(0, gp_axislh);
var vaxis = gamepad_axis_value(0, gp_axislv);
direction = point_direction(0, 0, haxis, vaxis);
speed = point_distance(0 ,0, haxis, vaxis) * 5;
The above code sets the speed and direction of the instance based on the returned values of the left analogue controller of the gamepad plugged into device "slot" 0.