Skip to content
KCKingdoms Connected Scripting APIScripting guides and API
Data shapeClient APIGenerated

WorldRayHit

Defined in: client/api.d.ts:1647

One thing a trace met, as the machine that traced it saw it.

category: "tree" | "bush" | "plant" | "rock" | null

Defined in: client/api.d.ts:1686

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: number

Defined in: client/api.d.ts:1661

How far along the ray it sits, in metres.


entityClass: string | null

Defined in: client/api.d.ts:1706

The engine class it belongs to – AnimDoor, NPC_NAI, GeomEntity. Null when nothing that carries a class was hit.


entityGuid: string | null

Defined in: client/api.d.ts:1696

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: number | null

Defined in: client/api.d.ts:1711

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: string | null

Defined in: client/api.d.ts:1701

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:1676

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.


material: string | null

Defined in: client/api.d.ts:1691

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:1681

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: Vector3

Defined in: client/api.d.ts:1656

The surface normal at that point, as a unit vector.


player: Player | null

Defined in: client/api.d.ts:1716

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: Vector3

Defined in: client/api.d.ts:1651

Where the ray met it, in world-space metres.


surface: string

Defined in: client/api.d.ts:1666

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: boolean

Defined in: client/api.d.ts:1671

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.