Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/BunnyNabbit/celaria-formats/llms.txt

Use this file to discover all available pages before exploring further.

Barrier is an invisible physics surface that slows down players who move through it. It extends Instance and can act as either a vertical wall or a horizontal floor depending on how its scale is configured. The instanceId is not fixed — it returns 3 for walls and 4 for floors — making scale a required constraint rather than an aesthetic choice.
Barriers require CelariaMap format version 2 or higher for serialization. Maps saved in an earlier format version cannot include barriers.

Constructor

new Barrier()
The constructor takes no arguments. It initializes position to [0, 0, 0], rotation to 0, and scale to [1, 0, 1] (a wall by default).

Properties

position
[number, number, number]
World-space position of the barrier, inherited from Instance. Defaults to [0, 0, 0]. Z is the gravity axis.
scale
[number, number, 0] | [number, 0, number]
The dimensions of the barrier surface. One axis component must be 0 to identify whether the barrier is a wall or a floor. Defaults to [1, 0, 1] (a wall).scale must conform to one of these two shapes:
ShapeTypeConditionRole
[x, y, 0]XYRestrainedVector3scale[2] === 0Floor — spans the XY plane
[x, 0, z]XZRestrainedVector3scale[1] === 0Wall — spans the XZ plane
Setting both scale[1] and scale[2] to non-zero values, or setting scale[0] to 0, produces an indeterminate state that throws an error when instanceId is accessed.
rotation
number
Rotation of the barrier surface around the Z axis, in radians. Defaults to 0.

Getters

instanceId
3 | 4
Returns 3 if the barrier is acting as a wall (scale[0] and scale[2] are both non-zero, with scale[1] equal to 0).Returns 4 if the barrier is acting as a floor (scale[0] and scale[1] are both non-zero, with scale[2] equal to 0).
If scale does not match either pattern, accessing instanceId throws Error("I can't decide if I am a wall or a floor."). Always ensure exactly one of scale[1] or scale[2] is 0 and scale[0] is non-zero before the barrier is serialized or its instanceId is read.

Wall vs floor

The role of a Barrier is determined entirely by its scale:
  • Wall (instanceId: 3): Set scale[1] to 0. The barrier spans the XZ plane — it stands vertically like a wall.
  • Floor (instanceId: 4): Set scale[2] to 0. The barrier spans the XY plane — it lies flat like a floor.
Wall:  scale = [width, 0, height]   →  instanceId 3
Floor: scale = [width, depth, 0]    →  instanceId 4

Examples

Creating a wall barrier

import { Barrier, EditableCelariaMap } from "celaria-formats"

const map = new EditableCelariaMap()

const wall = new Barrier()
// scale[1] = 0 → wall (instanceId 3)
wall.scale = [5, 0, 3]
wall.position = [0, 10, 0]
wall.rotation = Math.PI / 4   // 45-degree angle

map.instances.push(wall)

console.log(wall.instanceId) // 3

Creating a floor barrier

import { Barrier, EditableCelariaMap } from "celaria-formats"

const map = new EditableCelariaMap()

const floor = new Barrier()
// scale[2] = 0 → floor (instanceId 4)
floor.scale = [8, 8, 0]
floor.position = [0, 0, -1]

map.instances.push(floor)

console.log(floor.instanceId) // 4

Guarding against invalid scale

import { Barrier } from "celaria-formats"

function safeInstanceId(barrier) {
  try {
    return barrier.instanceId
  } catch (err) {
    console.error("Invalid barrier scale:", barrier.scale)
    return null
  }
}

const bad = new Barrier()
bad.scale = [2, 2, 2]  // Neither wall nor floor

safeInstanceId(bad)  // Logs error, returns null

Instance

Abstract base class that Barrier extends.

Map objects guide

Overview of all map object types and how to use them.

CelariaMap

Serialization class that requires version 2 for barriers.

Types reference

FlatVector3 and other type definitions.

Build docs developers (and LLMs) love