WorldRayHit
Defined in: client/api.d.ts:1824
One thing a trace met, as the machine that traced it saw it.
Properties
Section titled “Properties”category
Section titled “category”category:
"tree"|"bush"|"plant"|"rock"|null
Defined in: client/api.d.ts:1863
Which of the game’s own folders of natural objects model comes from: tree for objects/natural/vegetation/trees – living, dead, fallen and stumps alike, which model tells apart – bush for its bushes, plant for the rest of its vegetation (grass, ferns, mushrooms, branches), and rock for objects/natural/rocks and objects/natural/stones. Null for anything else, man-made included.
distance
Section titled “distance”distance:
number
Defined in: client/api.d.ts:1838
How far along the ray it sits, in metres.
entityClass
Section titled “entityClass”entityClass:
string|null
Defined in: client/api.d.ts:1883
The engine class it belongs to – AnimDoor, NPC_NAI, GeomEntity. Null when nothing that carries a class was hit.
entityGuid
Section titled “entityGuid”entityGuid:
string|null
Defined in: client/api.d.ts:1873
The level’s own identity for what was hit, as sixteen lowercase hex digits – the same on every machine, and what Door.find and the other GUID lookups take. Null for terrain, for static geometry and for anything the session spawned, none of which the level names.
entityId
Section titled “entityId”entityId:
number|null
Defined in: client/api.d.ts:1888
This machine’s own handle for it. Local to this client and to this session – it is not the network ID and it is not portable, so store entityGuid instead. Null for terrain and static geometry.
entityName
Section titled “entityName”entityName:
string|null
Defined in: client/api.d.ts:1878
The name the level gives it, often empty. Null when nothing that carries a name was hit.
kind:
"terrain"|"entity"|"vegetation"|"brush"|"static"
Defined in: client/api.d.ts:1853
What sort of thing the ray stopped on. entity is anything with an entityClass – doors, props, NPCs, players. vegetation is an instance the level paints on: trees, bushes, plants, and boulders painted the same way. brush is a static mesh placed one by one: walls, houses, rocks and cliffs. static is static geometry that is neither, or whose source the engine does not record. Trees and rocks are not entities, so for them this, model and category are what say what was hit.
levelObject
Section titled “levelObject”levelObject:
WorldLevelObject|null
Defined in: client/api.d.ts:1893
The object the level placed that was hit, named the way LevelEdit.apply finds it again on every machine, with where the level put it and how it turned and sized it. A tree, a rock or a wall is one; so is a door or any other entity the level gives a GUID. Null for terrain, for static geometry the engine records no source for, and for anything the session spawned – props, players, NPCs. Spread it into a definition to take the object out or swap it: LevelEdit.apply({ ...hit.levelObject, model: stump }).
material
Section titled “material”material:
string|null
Defined in: client/api.d.ts:1868
The material drawn where the ray met it, as the path the material manager keys it by, the sub-material when the mesh has several – a trunk’s bark rather than the tree’s whole material. Null for terrain and when nothing names one.
model:
string|null
Defined in: client/api.d.ts:1858
The mesh of a vegetation instance or a brush, as the path the game loads it from – objects/natural/vegetation/trees/normal_trees/quercus_robur/quercus_robur_big_a.cgf. Null for terrain, entities and static. A tree or a rock has no GUID, but its model and position together are the same on every client on the same level, which is what a server keeps a felled tree or a mined rock by.
normal
Section titled “normal”normal:
Vector3
Defined in: client/api.d.ts:1833
The surface normal at that point, as a unit vector.
player
Section titled “player”player:
Player|null
Defined in: client/api.d.ts:1898
The player whose body it was – the local player’s own included, when ignoreSelf is off – or null for anything else. Found through the body’s own entity, so it holds for a disguised player too: their collider is the mesh’s size, and a trace that meets the mesh names them.
position
Section titled “position”position:
Vector3
Defined in: client/api.d.ts:1828
Where the ray met it, in world-space metres.
surface
Section titled “surface”surface:
string
Defined in: client/api.d.ts:1843
The surface type’s own name, spelled the way the game’s tables spell it in Libs/MaterialEffects/SurfaceTypes.xml – mat_wood, mat_rock, mat_soil, mat_water. It says what the thing is made of, which is how footsteps and blows sound, not what it is: a plank wall is mat_wood as much as a trunk is, so tell a tree by category. Among the 74 the game defines: mat_wood, mat_wood_soft, mat_vegetation, mat_bushes, mat_rock, mat_rock_unwalk, mat_rock_horse_ignore, mat_stairs_stone, mat_gravel, mat_soil, mat_mud, mat_grass, mat_road, mat_metal, mat_glass, mat_plaster, mat_thatch, mat_fabric, mat_flesh. Empty only before the material tables are up.
terrain
Section titled “terrain”terrain:
boolean
Defined in: client/api.d.ts:1848
Whether the ground itself was hit rather than anything placed on it. Nothing lies behind the terrain, so a trace stops there. The same as kind being terrain.