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

WorldRayHit

Defined in: server/api.d.ts:6948

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

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

Defined in: server/api.d.ts:6987

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: server/api.d.ts:6962

How far along the ray it sits, in metres.


entityClass: string | null

Defined in: server/api.d.ts:7007

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


entityGuid: string | null

Defined in: server/api.d.ts:6997

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.


entityName: string | null

Defined in: server/api.d.ts:7002

The name the level gives it, often empty. Null when nothing that carries a name was hit.


kind: "brush" | "entity" | "terrain" | "vegetation" | "static"

Defined in: server/api.d.ts:6977

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: server/api.d.ts:6992

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: server/api.d.ts:6982

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: server/api.d.ts:6957

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


position: Vector3

Defined in: server/api.d.ts:6952

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


surface: string

Defined in: server/api.d.ts:6967

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: server/api.d.ts:6972

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.