Skip to content

YaInputAPI

YaInputAPI manages user input.

Functions

number YaInputAPI.OnAllTargetKeyDown(function callback<YaEntity, number>)

Returnsevent id
Listen for keyboard events for all players
  • callback callback func
    1. entity The input entity
    2. code Code YaInputCode
1
2
3
4
5
YaInputAPI.OnAllTargetKeyDown(function (entity, code)
    if (code == YaInputCode.A) then
        print("The A key is pressed")
    end
end)

number YaInputAPI.OnAllTargetKeyUp(function callback<YaEntity, number>)

Returnsevent id
Listen for keyboard events for all players
  • callback callback func
    1. entity The input entity
    2. code Code YaInputCode
1
2
3
4
5
YaInputAPI.OnAllTargetKeyUp(function (entity, code)
    if (code == YaInputCode.A) then
        print("The A key is release")
    end
end)

number YaInputAPI.OnKeyDown(YaEntity entity, function callback<YaEntity, number>)

Returnsevent id
Listens for keyboard events on an avatar entity or a tool equipped on an avatar entity.
  • entity The input entity
  • callback callback func
    1. entity The input entity
    2. code Code YaInputCode
1
2
3
4
5
YaInputAPI.OnKeyDown(selfEntity, function (entity, code)
    if (code == YaInputCode.A) then
        print("The A key is pressed")
    end
end)

number YaInputAPI.OnKeyUp(YaEntity entity, function callback<YaEntity, number>)

Returnsevent id
Listens for keyboard events on an avatar entity or a tool equipped on an avatar entity.
  • entity The input entity
  • callback callback func
    1. YaEntity The input entity
    2. Keycode YaKeycode
1
2
3
4
5
YaInputAPI.OnKeyUp(selfEntity, function (entity, code)
    if (code == YaInputCode.A) then
        print("The A key is release")
    end
end)

void YaInputAPI.Move(YaEntity entity, float3 vector, boolean sprint)

SERVER ONLY 
Set the movement input of the current entity
  • entity Entity that accepts input
  • vector Vector input vector. The meaning of the actual vector is determined by the entity, usually the character represents the world space, and the vehicle is the local space
  • sprint Whether to sprint

void YaInputAPI.StopMove(YaEntity entity)

SERVER ONLY 
Stop mobile typing
  • entity Entity that accepts input

void YaInputAPI.Jump(YaEntity entity)

SERVER ONLY 
Execute the jump input of the current entity, if there is no jump, it has no effect
  • entity Entity that accepts input

void YaInputAPI.Attack(YaEntity entity)

SERVER ONLY 
Execute the attack input of the current entity, if there is no attack action Ability, it will not be executed
  • entity Entity that accepts input

float2 YaInputAPI.GetLocalLeftJoystickValue()

CLIENT ONLY 
Returnsa float2 containing the x and y directional input values of the left joystick.
Gets the input value of the left joystick for the local player.

number YaInputAPI.OnMousePress(function callback<number, float2>)

CLIENT ONLY 
Returnsevent id
Fired when the local character entity press the mouse. This API only works for device with mouse
  • callback callback func
    1. code Code YaInputCode
    2. screenPosition The position of mouse in screen position

number YaInputAPI.OnMouseRelease(function callback<number, float2>)

CLIENT ONLY 
Returnsevent id
Fired when the local character entity release the mouse. This API only works for device with mouse
  • callback callback func
    1. code Code YaInputCode
    2. screenPosition The position of mouse in screen position

number YaInputAPI.OnMouseScroll(function callback<number, float2>)

CLIENT ONLY 
Returnsevent id
  • callback callback func
    1. code Code YaInputCode
    2. scroll delta The mouse scroll delta

number YaInputAPI.OnFingerDown(function callback<number, float2>)

CLIENT ONLY 
Returnsevent id
Fired when the local character entity use finger press down to the screen. This API only works for device with touch screen
  • callback callback func
    1. fingerIndex The index of finger
    2. screenPosition The position of finger in screen position

number YaInputAPI.OnFingerMove(function callback<number, float2>)

CLIENT ONLY 
Returnsevent id
Fired when the local character entity use finger move on the screen. This API only works for device with touch screen
  • callback callback func
    1. fingerIndex The index of finger
    2. screenPosition The position of finger in screen position

number YaInputAPI.OnFingerUp(function callback<number, float2>)

CLIENT ONLY 
Returnsevent id
Fired when the local character entity use finger press up from the screen. This API only works for device with touch screen
  • callback callback func
    1. fingerIndex The index of finger
    2. screenPosition The position of finger in screen position

float2 YaInputAPI.GetMousePosition()

CLIENT ONLY 
ReturnsThe position of cursor position
Get the local character mouse position. This API only works for device with mouse

boolean YaInputAPI.HasMouse()

CLIENT ONLY 
ReturnsHas cursor
If the device has mouse, it returns true.

boolean YaInputAPI.HasTouchScreen()

CLIENT ONLY 
ReturnsHas touch screen
If the device has touch screen, it returns true