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
float3 GetPosition()¶
ReturnsThe position of the entity
Gets the entity's position in local space.