Skip to content

Place units, doodads and prefabs ​

Put units, buildings, scenery, camps and markers on the map, name them for your rules, and reuse groups of them as prefabs.

Put down units and buildings ​

  1. Open Place (left rail) or the Content drawer (Ctrl+Space).
  2. Pick a unit type, and the player who owns it in the owner list.
  3. Click the map to put it down, or drag it from the drawer into the scene.
  4. Turn it before the click with [ and ].

Buildings snap to whole cells and show red where they do not fit. Units stand still on the map (the first frame of their idle); View › Animate units plays their idle.

Lay a wall ​

  1. Pick a wall piece in Place (a type with UnitTypeDef.wall).
  2. Drag from one end to the other: a piece goes on every cell of the line, the longer way first.

The world shapes each piece (end, straight, corner, tee, cross) from its neighbours when the game turns walls on (wallsPack).

Put down trees and scenery ​

  1. Open Place › Doodads, or Content's scenery.
  2. Click to put one down, or drag it in.
  3. Use the Place panel's random turn and random size to vary each one.

Doodads are scenery, not units: the rules never see them, only what they block. Each has a full transform, a tint, and whether it blocks walking or building. A doodad whose model has clips gets an Animation in the Inspector.

Put down a creep camp ​

  1. Open Place and pick creeps from a group that makes camps.
  2. Put the units down together: they form a camp.
  3. Name the camp in the Inspector if your rules need it.

View › Camps notice (Shift+C) shows how far each camp notices who comes near.

Give a unit first orders ​

  1. Select a placed unit that moves.
  2. In the Inspector, under First orders, add orders: go, patrol, guard or hold.
  3. Point each at a point or path of the map by its name.

A patrol along a path walks it back and forth. The orders run as the game starts.

Set what a placed unit starts as ​

  1. Select it.
  2. In the Inspector, set its health, mana, items, and how long it lasts (For good, 10 s, 30 s, 60 s, or typed).

Mark regions, points and paths ​

  1. Press G for regions (a rectangle, circle or polygon), P for a point, L for a path.
  2. Click or drag on the map to lay it.
  3. Name it in the Inspector, and set its size, width or facing there.
  4. To change it later, pick it with its tool or the select tool and drag.

The region tool also draws mist, weather and cloud areas for the Look panel. Drop a cinematic from Content onto the map to make a region that plays it when a unit walks in.

Name things for your rules ​

  1. Select the thing.
  2. Type its name in the Inspector (or press F2 in the Hierarchy).
  3. Save. The editor writes <map>.names.ts beside the map, so the names are types in your code.

Your rules find each kind of thing by its name:

On the mapIn the rules
A unit or a buildingworld.named('gate')
A campcampNamed(world, 'ogres')
A regionAn area of the world: world.areas, enteredArea, leftArea
A point, facing a wayworld.map.point('entry')
A path, with a widthworld.map.path('road'), a Path to walk and measure
A camera (a saved view)cut.camera('gate') in a cinematic, client.lookFrom('gate')
A doodadclient.doodads.named('wall')
A thing of your game's own kindworld.map.things('td.clearings')

Renaming a path or a region takes the map's uses of its name along, in the same step: the first orders of units that follow the path, and the mist, weather, cloud and picture zones over the region and the detail levels that name it. Your code and the cinematics keep the old name: <map>.names.ts shows where they break.

ts
import type { RoadPaths } from './maps/road.names'

// a typo in the name is a compile error
const road = world.map.path<RoadPaths>('road')

A name belongs to one thing on a map: the editor refuses a second.

Add fields of your own to placed things ​

Declare a field once, and the Inspector shows it on what it is for:

ts
const spawns = defineMapField({ id: 'td.wave', name: 'Sends wave', kind: 'number', for: ['spawner'], min: 1, default: 1 })

export const myGame: Rules = {
	// ...
	editor: { fields: [spawns] }
}

Read the value where the thing comes into the world:

ts
hooks: [defineHook({ hook: 'mapObject', id: 'td.spawnerWave', run: (world, { entity, data }) => entity.set(waveOf, data['td.wave'] as number) })]

See field options in the reference.

Save a group as a prefab ​

  1. Select the things (units, doodads, markers).
  2. In the Inspector, press Save as a prefab and name it. Tick With the ground under it to bring the heights, water and paint too.
  3. Put it down from Place › Prefabs or Content. R turns it a quarter, [ ] turn it freely.
  4. A click on a part selects the whole instance; Alt+click picks one part.

The prefab file is prefabs/<name>.prefab.json in your game's folder. A map with instances plays the same as one without them: the game never reads prefab files.

Update instances after changing a prefab ​

  1. Right-click the prefab in Content or Place and pick Edit: it opens on a stage of its own.
  2. Change it and press Save (‹ Back returns to the map).
  3. Each instance on the map is now behind; Problems says so. Select one and press Update in the Inspector. Your changes to that instance are kept.

The Inspector also has Revert (make it anew), Apply to prefab (write this instance back), Unpack (plain things again) and Select every. Make a variant of it… makes a prefab that is another one with some fields changed.

Lay decals ​

  1. Open Place › Decals: scorches, blood, cracks, road marks, runes.
  2. Click to lay one, or drag it in. [ and ] turn it.
  3. Select it to change its look, size, facing, tint and fade in the Inspector.

Drop a picture from the Assets panel onto the palette to make a decal of it. Decals are drawn only: the rules do not see them. A game gives its decal looks in its view:

ts
import { presetDecals, type GameView } from '@v12-engine/client'

const view: GameView = {
	units: { looks: {} },
	ground: { decals: { ...presetDecals(), moss: { name: 'Moss', texture: 'stain', tint: [0.3, 0.45, 0.2], size: 4 } } }
}

Place lights, effects and sounds ​

Press I for the light tool and X for the effect tool, then click the map. See Look panel for lights and Effects for placed effects.

In code ​

ts
// prefabs
editor.clipboard.placePrefab('fort', { x: 40, z: 40 }, { turn: 0, scale: 1 })
editor.clipboard.makeVariant('fort', 'big-fort')
editor.clipboard.updatePrefabInstance(instance.id)

// walls
mapEditor.batch.placeWall('wall', 1, { x: 10, z: 10 }, { x: 20, z: 10 })

// decals
editor.doc.look.addDecal({ x: 32, z: 32 }, { look: 'scorch' })
editor.setTool({ kind: 'decal', look: 'scorch' })

// copies across the symmetry, and what stands at the mirrors
mapEditor.batch.mirrorItems('objects', ids)

Reference ​

Map fields ​

OptionWhat it is
idThe field's id; give it your game's prefix
nameWhat the Inspector calls it
kindnumber, text, toggle, a choice, a unit type, a player; a region, point or path; a colour; a list of words; a place { x, z }
forUnit types, a function of the type, 'camp', 'region', 'player' or 'map'
defaultIts value where it was not set
Where it is keptWhere the game reads it
MapObject.data, and the camp's and region's dataThe hooks mapObject, mapCamp, mapRegion
MapPlayer.dataworld.map.player(id).data
GameMap.dataworld.map.data

A region, point or path field is picked by name and kept by id, so renaming does not lose it. A field naming something that was removed is a map error (missing-target).

Prefabs ​

ActionIn code
Place oneeditor.clipboard.placePrefab(name, at, { turn, scale })
List instanceseditor.doc.prefabs.prefabInstances(), editor.doc.prefabs.instanceOf(target)
Update, reverteditor.clipboard.updatePrefabInstance(id), revertPrefabInstance(id)
Apply, unpackeditor.clipboard.applyPrefabInstance(id), unpackPrefabInstance(id)
Select instanceseditor.clipboard.selectPrefabInstance(s)
Resolve a fileresolvePrefab(file, read), resolvePrefabs(files), prefabsWithin

The map records instances in GameMap.editor (PrefabInstance). Nested prefabs are PrefabFile.prefabs (NestedPrefab); variants are PrefabFile.variant. Problems flags a prefab inside itself (prefab-loop) and a missing source (prefab-source-missing). The bus says prefab.placed and prefab.updated. Prefabs defined in code (Rules.prefabs, see prefabs in code) are listed too, read-only.

Decals ​

FieldWhat it is
lookA decal look of the game's, or a picture's path
x, zWhere it lies
facingIts turn
sizeIts size in cells
tintA colour over it
fade0 to 1

Decals are MapDecal, kept in MapEnvironment.decals. Looks are GameView.ground.decals (DecalLook; blend: 'add' for a glowing rune). In code: look.setDecal(id, change), look.removeDecals(ids), editor.tool.newDecal(look); in a game, client.mapDecals.stats. All decals of one picture are drawn in one mesh per chunk, so 200 decals cost about three meshes.

Players and the palette ​

What a game puts in Place is its palette (MapEditorDef): groups of types, each saying who owns what it puts down (MAP_CREEPS, MAP_NEUTRAL) and whether its units make camps. The default is defaultPalette. See Panels.