gamepad_axis_value

Returns a value based on the current axis position.

Syntax:

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


Description

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).


Example:

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.


Back: GamePad Input
Next: gamepad_button_check
© Copyright YoYo Games Ltd. 2018 All Rights Reserved