YaInputAPI
YaInputAPI manages user input.Functions
number YaInputAPI.OnAllTargetKeyDown(function callbackYaEntity, number>)
Returnsevent id
Listen for keyboard events for all playerscallbackcallback funcentityThe input entitycodeCodeYaInputCode
YaInputAPI.OnAllTargetKeyDown(function (entity, code)
if (code == YaInputCode.A) then
print("The A key is pressed")
end
end)
number YaInputAPI.OnAllTargetKeyUp(function callbackYaEntity, number)
Returnsevent id
Listen for keyboard events for all playerscallbackcallback funcentityThe input entitycodeCodeYaInputCode
YaInputAPI.OnAllTargetKeyUp(function (entity, code)
if (code == YaInputCode.A) then
print("The A key is release")
end
end)
number YaInputAPI.OnKeyDown(YaEntity entity, function callbackYaEntity, number)
Returnsevent id
Listens for keyboard events on an avatar entity or a tool equipped on an avatar entity.entityThe input entitycallbackcallback funcentityThe input entitycodeCodeYaInputCode
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 callbackYaEntity, number)
Returnsevent id
Listens for keyboard events on an avatar entity or a tool equipped on an avatar entity.entityThe input entitycallbackcallback funcYaEntityThe input entityKeycodeYaKeycode
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
entityEntity that accepts inputvectorVector 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 spacesprintWhether to sprint
void YaInputAPI.StopMove(YaEntity entity)
SERVER ONLY
Stop mobile typing
entityEntity 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
entityEntity 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
entityEntity 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 callbacknumber, float2)
CLIENT ONLY
Returnsevent id
Fired when the local character entity press the mouse. This API only works for device with mousecallbackcallback funccodeCodeYaInputCode screenPositionThe position of mouse in screen position
number YaInputAPI.OnMouseRelease(function callbacknumber, float2)
CLIENT ONLY
Returnsevent id
Fired when the local character entity release the mouse. This API only works for device with mousecallbackcallback funccodeCodeYaInputCode screenPositionThe position of mouse in screen position
number YaInputAPI.OnMouseScroll(function callbacknumber, float2)
CLIENT ONLY
Returnsevent id
callbackcallback funccodeCodeYaInputCode scroll deltaThe mouse scroll delta
number YaInputAPI.OnFingerDown(function callbacknumber, 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 screencallbackcallback funcfingerIndexThe index of fingerscreenPositionThe position of finger in screen position
number YaInputAPI.OnFingerMove(function callbacknumber, 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 screencallbackcallback funcfingerIndexThe index of fingerscreenPositionThe position of finger in screen position
number YaInputAPI.OnFingerUp(function callbacknumber, 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 screencallbackcallback funcfingerIndexThe index of fingerscreenPositionThe 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 mouseboolean 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