⚙️ method Bot.CreateUnit(...)

Last updated:4/16/2026

URL

https://github.com/42core-team/monorepo/blob/dev/bots/go/client_lib/actions.go

Description

Creates a new unit of specified type.

Your core needs to own a certain amount of money to be able to create a unit. This amount is different depending on the type of unit and can be found in the config.

Cores with a spawn cooldown that isn't 0 are unable to spawn new units. More info on spawn cooldowns.

Units are spawned as close to your core as possible - but if all positions directly next to your core are occupied, a flood fill algorithm will be used looking for the next empty space and the unit will be placed there.

Signature

func (b *Bot) CreateUnit(unitType game.UnitType)

Parameters

  • unitType game.UnitType: The type of unit to create

Return

void

Examples

warriors := g.ObjectsFilter(func(obj *game.Object) bool {
	data := obj.GetUnitData()
	return obj.Type == game.ObjectUnit && data != nil && data.TeamID == g.MyTeamID && data.UnitType == game.UnitWarrior
})
if len(warriors) < 3 {
	b.CreateUnit(game.UnitWarrior)
}