GetInputAxisValue: Difference between revisions

From Onset Developer Wiki
(Created page with "{{Info|Function|Client|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|GetInputAxisValue(AxisName)}} {{FuncParameters}} {{FuncParam|AxisName|__EDIT_ME__}} {{FuncReturnV...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Info|Function|Client|1.0}}
{{Info|Function|Client|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|Gets the value of input axis keys.}}
{| class="wikitable" style="text - align: center; "
!colspan = "6" | Axis Mappings
|-
|AxisName
|Keys
|-
|MoveForward
|W, S, Up, Down, Gamepad Left Thumbstick Y-Axis
|-
|MoveRight
|A, D, Gamepad Left Thumbstick X-Axis
|-
|Turn
|Mouse X
|-
|LookUpRate
|Gamepad Right Thumbstick Y-Axis
|-
|LookUp
|Mouse Y
|-
|Throttle
|W, Gamepad Right Trigger
|-
|Brake
|S, Gamepad Left Rigger
|-
|MoveVertical
|Left Shift, Left Ctrl
|-
|MoveTurn
|E, Q
|-
|Handbrake
|Space Bar
|}


{{FuncSyntax|GetInputAxisValue(AxisName)}}
{{FuncSyntax|GetInputAxisValue(AxisName)}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|AxisName|__EDIT_ME__}}
{{FuncParam|AxisName|Name of the input axis key.}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|Returns the value of the input axis key between -1.0 and 1.0.}}


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
function OnRenderHUD()
    local IsMovementInput = (math.abs(GetInputAxisValue("MoveForward")) + math.abs(GetInputAxisValue("MoveRight"))) not 0.0;
    if IsMovementInput then
        DrawText(10, 10, "You are moving")
    end
end
AddEvent("OnRenderHUD", OnRenderHUD)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
*[[IsCtrlPressed]]
*[[IsShiftPressed]]
*[[IsAltPressed]]
*[[IsCmdPressed]]
*[[SetIgnoreMoveInput]]
*[[SetIgnoreLookInput]]
*[[SetControlRotation]]
*[[GetInputAxisValue]]

Latest revision as of 18:29, 30 August 2020

GetInputAxisValue

Type: Function
Context: Client
Introduced: v1.0

Description

Gets the value of input axis keys.

Axis Mappings
AxisName Keys
MoveForward W, S, Up, Down, Gamepad Left Thumbstick Y-Axis
MoveRight A, D, Gamepad Left Thumbstick X-Axis
Turn Mouse X
LookUpRate Gamepad Right Thumbstick Y-Axis
LookUp Mouse Y
Throttle W, Gamepad Right Trigger
Brake S, Gamepad Left Rigger
MoveVertical Left Shift, Left Ctrl
MoveTurn E, Q
Handbrake Space Bar

Syntax

GetInputAxisValue(AxisName)

Parameters

  • AxisName
    Name of the input axis key.

Return Value

  • Returns the value of the input axis key between -1.0 and 1.0.

Example

function OnRenderHUD()
    local IsMovementInput = (math.abs(GetInputAxisValue("MoveForward")) + math.abs(GetInputAxisValue("MoveRight"))) not 0.0;
    if IsMovementInput then
        DrawText(10, 10, "You are moving")
    end
end
AddEvent("OnRenderHUD", OnRenderHUD)

See also