GetInputAxisValue: Difference between revisions

From Onset Developer Wiki
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 47: Line 47:


== 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