Besiege – AI Turret Building

AI Turret Building Tutorial Objects needs Turret model. TriggerA for aiming. TriggerB for detect “Hit”. (hidden) […]

AI Turret Building Tutorial

Objects needs

  • Turret model.
  • TriggerA for aiming.
  • TriggerB for detect “Hit”. (hidden)
  • Bullet model. (hidden)
  • Bomb that Explodes. (hidden)
  • a Cube that controls the movement of the turret.
  • TriggerC and TriggerD to limit the search range of the turret.

To hide those 3 hidden objects in the list, at the first page of each object there will be an eye button on the left top corner, click it to hide the object when the level starts.

Turret Placement


Located at the center of the turret while facing forward (turn 90 degrees forward) where the turret aims at.
It can be flat or just a straight line.


Same as the TriggerA, but its shape should be a cube. (x,y,z= 5,3,5 for example)

Bullet Model

Place it at the center of the turret, facing forward, a thin Sphere as the model is suggested.


Same as where the Bullet model is, also facing forward.


Place it wherever you want.

TriggerC and TriggerD

Place the two triggers where it should touch the turret as the turret is on the maximum angle.


Logic in TriggerA:

When “any player object” enter
—reset “Cube”
—modify variable “fire +1”

When “modify variable” “fire= 1”
—“local” transform “TriggerB, Bomb, Bullet model” to “y=(value)”
(the “y” value must be longer than the barrel, so when the Bomb is activated it won’t explode inside the turret.)
—activate “TriggerB, Bomb, Bullet model”
—“duration=2” transform “TriggerB, Bomb, Bullet model” to “local distance: y=1000”

Logic in TriggerB:

When “any player object” enter
—deactivate “TriggerA, TriggerB, Bullet model”
—activate “Bomb”

Logic in Bomb:

When “activated”
—“instant” transform “local distance: y=-5”
—“force” transform “local distance: y=100”

When explode
—modify variable “Cube” “reset=1”

Logic in Cube:

When modify variable “move= 1”
—turn “everything(note*1) of the turret” by “y=1”
(the “y” value depends on how fast it is required.)
—repeat infinitely.

When modify variable “move= 0”
—turn “everything of the turret” by “y=-1”
—repeat infinitely.

When modify variable “reset=1”
—activate “TriggerA, TriggerB, Bomb, Bullet model”
—reset “Everything including the turret model but except self”
—modify variable “TriggerA” “fire=0”
—deactivate “TriggerA”
—activate “TriggerA”

Logic in TriggerC:

When “(turret part)” enter (note*2)
—reset “Cube”
—modify variable “Cube” “move= 1”

Logic in TriggerD:

When “(turret part)” enter
—reset “Cube”
—modify variable “Cube” “move= 0”


Moving several objects around a same specific point takes a while to program, I will only show an example to do so.

Here’s the example:

If an Object has to move “ x + 10 “ to reach the axis, logic would be like:

—“instant” transform “Object” “x=10” (Must be Instant Movement)
—“duration= 0.1” transform “Object” by “global distance: axis y=10”
—“instant” transform “Object” “x=-10” (Must be Instant movement)
—repeat infinitely

in this case, the Object would move around the certain axis with 10m in range per 0.1 seconds infinitely.

Another thing you must know is that if the object is angled, the distance movement and the axis movement Must be separated.

Note 2

When a turret is turning, there must be a part that swings left and right, especially the barrel,
and that is where the turret part should touch TriggerC/D, which let us limit the search range of the turret.

Leave a Comment

Your email address will not be published. Required fields are marked *