YaInputAPI¶
YaInputAPI
manages user input.Functions¶
number YaInputAPI.OnAllTargetKeyDown(function callback<YaEntity, number>)¶
Returnsevent id
Listen for keyboard events for all players
callback
callback funcentity
The input entitycode
CodeYaInputCode
1 2 3 4 5 |
|
number YaInputAPI.OnAllTargetKeyUp(function callback<YaEntity, number>)¶
Returnsevent id
Listen for keyboard events for all players
callback
callback funcentity
The input entitycode
CodeYaInputCode
1 2 3 4 5 |
|
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 entitycallback
callback funcentity
The input entitycode
CodeYaInputCode
1 2 3 4 5 |
|
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 entitycallback
callback funcYaEntity
The input entityKeycode
YaKeycode
1 2 3 4 5 |
|
void YaInputAPI.Move(YaEntity entity, float3 vector, boolean sprint)¶
SERVER ONLY
Set the movement input of the current entity
entity
Entity that accepts inputvector
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 spacesprint
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 funccode
CodeYaInputCode 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 funccode
CodeYaInputCode screenPosition
The position of mouse in screen position
number YaInputAPI.OnMouseScroll(function callback<number, float2>)¶
CLIENT ONLY
Returnsevent id
callback
callback funccode
CodeYaInputCode 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 funcfingerIndex
The index of fingerscreenPosition
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 funcfingerIndex
The index of fingerscreenPosition
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 funcfingerIndex
The index of fingerscreenPosition
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