Unit
Something a team can select and order about with no code: click it (or drag a box round it) and right-click where it should go or what it should attack. It walks around buildings, rocks and walls on its own, and units stand apart rather than on top of each other. Give it a Health to be hurt, a Fighter to fight, and a Worker to gather and build.
Part of the Strategy module: Real-time strategy: factions, units that walk around obstacles and fight, workers that gather and build, buildings that train units, fog of war, the computer playing a side, the player’s controls and HUD, playing online team against team, and the Strategy template.
A unit made by a Producer is a prefab; its Cost, TrainTime, Supply and Hotkey say what training it takes. Scripts can order it about with MoveTo, AttackMoveTo, Attack, Stop and Hold.
Works with: Health (so it can be hurt); Fighter (so it can fight); Worker (so it can gather and build)
Needed by: Worker
Properties
Section titled “Properties”Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.
team: text = “Player”. The team it’s on: a Faction’s Team, e.g. “Player” or “Enemy”. (Names a team.) (Field: a name.)speed: a number = 3. World units per second. (Field: a number.)radius: a number = 0.4. How much room it takes up: for clicking it, its selection ring, and keeping others off it. (A distance: the Scene view draws it as a circle around the entity, with a handle to drag.) (Field: a number.)sight: a number = 6. How far it sees through the fog of war, and how close an enemy has to come for it to notice. (A distance: the Scene view draws it as a circle around the entity, with a handle to drag.) (Field: a number.)supply: a whole number = 1. The supply it takes up. A team can only have as much as its buildings provide. (Field: a number.)cost: text = “50 Gold”. What training it costs, e.g. “50 Gold” or “60 Gold, 20 Wood”. (Resources and how many of each, separated by commas, e.g. “150 Gold, 50 Wood”. The Inspector lists them a row each, the resource picked from the project’s and the count set.) (Field: its own editor: Counts.)trainTime: a number = 3. Seconds a Producer takes to train it. (Field: a number.)hotkey: text = null. The key that trains it from a building, e.g. “W”. Empty uses its first letter. (Names a letter key; the Inspector picks from them and flags a name that isn’t one. Empty for none.) (Field: its own editor: Choice Of.)
While the game runs
Section titled “While the game runs”Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.
order: one of Idle, Move, AttackMove, Attack, Hold, Gather, Return, Build. What it’s doing now. (Sent in a network game.)destination: [x, y]. Where it’s headed, for UnitOrder.Move and UnitOrder.AttackMove.target: an entity: its name, id or path. What it’s attacking, gathering from or building, if anything.isSelected: true or false. True while the player has it selected.
Scripts use it as Unit: its methods, events and values that aren’t saved with the scene.