YaEntity¶
YaEntity
identifies an object in games. YaEntity
can only function when the YaEntity module (https://developer.yahaha.com/manual/yahaha-studio-manual/scripting/module/module-reference/YaEntity/) is added to the same object.Functions¶
number GetEntityId()¶
ReturnsThe ID number
Get the entity ID for the entity.
1 2 |
|
boolean IsEmpty()¶
ReturnsTrue if the entity value represents no entity
Checks whether the entity value represents an entity.
Some APIs can return an entity that is empty (e.g., physics query APIs).
In that case, use this API to check the result.
1 2 3 4 5 6 7 |
|
boolean IsAlive()¶
ReturnsFalse if the entity value represents an eliminated entity or an empty entity, otherwise true
Checks whether the entity value represents an existing entity (different from the idea of method IsEmpty
).
If an entity value is stored for latter usage, this method can help check whether the entity still exists (if users are not sure about the existence).
Empty entities always not alive.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
boolean HasTag(string tag)¶
Returnstrue if the YaEntity has the tag.
Checks if the YaEntity has the tag.
tag
The name of the tag
YaEntity YaEntity.GetEntityById(number entityId)¶
ReturnsThe corresponding entity
Get the entity by the entity ID.
Under the case the entity does not exist, the IsEmpty
method would return true.
entityId
The entity ID that was retrieve by theYaEntity.EntityId field
Array<YaEntity> YaEntity.GetEntitiesByTag(string tag)¶
Returnsan array of YaEntities.
Gets all YaEntities that contain the specified tag.
tag
The name of the tag
void SetRotationEuler(float3 rotation)¶
Sets the entity's rotation as Euler angles in degrees.
Though this API is available both on clients and on servers, we recommend using it on the server to get consistent results.
rotation
The rotation of the entity
void SetRotationQuaternion(quaternion rotation)¶
Sets the entity's rotation as a quaternion.
Though this API is available both on clients and on servers, we recommend using it on the server to get consistent results.
rotation
The rotation of the entity
void SetGlobalRotationEuler(float3 rotation)¶
Sets the entity's rotation in world space as Euler angles in degrees.
Though this API is available both on clients and on servers, we recommend using it on the server to get consistent results.
rotation
The rotation of the entity
void SetGlobalRotationQuaternion(quaternion rotation)¶
Sets the entity's rotation in world space as a quaternion.
Though this API is available both on clients and on servers, we recommend using it on the server to get consistent results.
rotation
The rotation of the entity
float3 GetRotationEuler()¶
ReturnsThe rotation of the entity
Gets the entity's rotation as Euler angles in degrees.
quaternion GetRotationQuaternion()¶
ReturnsThe rotation of the entity
Gets the entity's rotation as a quaternion.
float3 GetGlobalRotationEuler()¶
ReturnsThe rotation of the entity
Gets the entity's rotation in world space as Euler angles in degrees.
quaternion GetGlobalRotationQuaternion()¶
ReturnsThe rotation of the entity
Gets the entity's rotation in world space as a quaternion.
void SetPosition(float3 position)¶
Sets the entity's position.
Though this API is available both on clients and on servers, we recommend using it on the server to get consistent results.
position
The position of the entity
void SetGlobalPosition(float3 position)¶
Sets the entity's position in world space.
Though this API is available both on clients and on servers, we recommend using it on server scripts to get consistent result.
position
The position of the entity
float3 GetPosition()¶
ReturnsThe position of the entity
Gets the entity's position in local space.
float3 GetGlobalPosition()¶
ReturnsThe position of the entity
Gets the entity's position in world space.
float3 GetScale()¶
ReturnsThe scale of the entity
Gets the entity's scale.
float3 GetGlobalLossyScale()¶
ReturnsThe scale of the entity
Gets the entity's scale.