Under construction. More sets are on the way.
Home
GAME

Enemy Patrol

6 ways to patrol

Tested in Unity · Godot · Web
1

Waypoint patrol

Walks a fixed loop of corners, pausing at each.

prompt.txt3,597 chars
Waypoint patrol: Walks a fixed loop of corners, pausing at each.

Goal: Make my enemy patrol a fixed loop of waypoints, so it feels methodical: the same route every time, with a short pause at each corner.

Use what my project already has:
- The player and the enemy. If either is missing, add a placeholder: one plain solid-colored square or circle, made with my engine's most basic built-in shape or sprite object. A placeholder player moves with WASD or the arrow keys at a constant speed, with no acceleration.
- If you add a placeholder player, put it a quarter of the way across the screen from the left, halfway down. If you add a placeholder enemy, put it 80% of the way across and 30% of the way down.
- Take every speed, distance and size from what my game already uses: the enemy's move speed and size, the player's speed. If there are no such values, make the player cross the screen in 2.5 seconds, set the enemy's speed to 90% of the player's, and size characters at 1/16 of the screen height.

Behavior. The pseudocode below is the exact behavior. Translate it line by line into my engine's language; keep every number, and do not add, remove, reorder or smooth anything:

    at start:
      home = enemy.pos
      points = [home + (-3, -1.5) * body, home + (3, -1.5) * body,
                home + (3, 1.5) * body,   home + (-3, 1.5) * body]
      i = 0; wait = 0
    
    every frame:
      if wait > 0:
        wait -= dt
        return                                       # stands still while it pauses
      toPoint = points[i] - enemy.pos
      step = 0.6 * speed * dt                        # a walk, not a run
      if length(toPoint) <= step:
        enemy.pos = points[i]
        i = (i + 1) % 4                              # next corner, round and round
        wait = 0.5
      else:
        enemy.pos += normalize(toPoint) * step

In the pseudocode:
- pos is a center position on the play plane (the ground plane in 3D). body is the enemy's body length, its larger side. speed is the enemy's move speed. dt is this frame's delta time in seconds.
- normalize of a zero vector is the zero vector. perpendicular(v) is v turned 90 degrees on the play plane.
- "pos += x" means move by x this frame. If my project moves characters through physics or its own movement code, make the same move through that (velocity = x / dt) instead of setting the position directly, so walls still stop it.

Edge cases:
- Frame-rate independent: scale every movement and every timer by the frame's delta time.
- Works in 2D and 3D. In 3D, move on the ground plane.
- The enemy has no physical collision with the player: it never pushes, blocks or knocks back the player, and the two can overlap.
- Add only what is described here. No health, damage, knockback, sound, particles, trails, UI, walls or obstacles, and do not change how the player moves. If my project already has any of these, leave them exactly as they are.

The feel depends on these, so keep them exactly:
- The same rectangle every lap, in the same order.
- A short, clear pause at every corner.

Before you finish, check your work:
- Is the loop a rectangle 6 body lengths wide and 3 tall, centered on where the enemy starts?
- Does it pause 0.5 seconds at each corner and ignore the player?
- Does every number come from my project or the fallback above, with nothing left for me to set?
- Does it behave the same at 30 and 144 frames per second?
- Does the project run with no errors or warnings in my engine version, as soon as I start the game, with no extra setup?
- Did you add nothing beyond what is described?

Works with any AI coding tool. Paste it into your project and run.

2

Ping-pong patrol

Paces back and forth between two points.

prompt.txt3,455 chars
Ping-pong patrol: Paces back and forth between two points.

Goal: Make my enemy patrol back and forth between two points, so it feels predictable: the player can learn its rhythm and slip past.

Use what my project already has:
- The player and the enemy. If either is missing, add a placeholder: one plain solid-colored square or circle, made with my engine's most basic built-in shape or sprite object. A placeholder player moves with WASD or the arrow keys at a constant speed, with no acceleration.
- If you add a placeholder player, put it a quarter of the way across the screen from the left, halfway down. If you add a placeholder enemy, put it 80% of the way across and 30% of the way down.
- Take every speed, distance and size from what my game already uses: the enemy's move speed and size, the player's speed. If there are no such values, make the player cross the screen in 2.5 seconds, set the enemy's speed to 90% of the player's, and size characters at 1/16 of the screen height.

Behavior. The pseudocode below is the exact behavior. Translate it line by line into my engine's language; keep every number, and do not add, remove, reorder or smooth anything:

    at start:
      home = enemy.pos
      ends = [home + (-3, 0) * body, home + (3, 0) * body]   # a straight line through home
      i = 1; wait = 0
    
    every frame:
      if wait > 0:
        wait -= dt
        return                                       # stands still at the end
      toEnd = ends[i] - enemy.pos
      step = 0.6 * speed * dt
      if length(toEnd) <= step:
        enemy.pos = ends[i]
        i = 1 - i                                    # turn around
        wait = 1.0
      else:
        enemy.pos += normalize(toEnd) * step

In the pseudocode:
- pos is a center position on the play plane (the ground plane in 3D). body is the enemy's body length, its larger side. speed is the enemy's move speed. dt is this frame's delta time in seconds.
- normalize of a zero vector is the zero vector. perpendicular(v) is v turned 90 degrees on the play plane.
- "pos += x" means move by x this frame. If my project moves characters through physics or its own movement code, make the same move through that (velocity = x / dt) instead of setting the position directly, so walls still stop it.

Edge cases:
- Frame-rate independent: scale every movement and every timer by the frame's delta time.
- Works in 2D and 3D. In 3D, move on the ground plane.
- The enemy has no physical collision with the player: it never pushes, blocks or knocks back the player, and the two can overlap.
- Add only what is described here. No health, damage, knockback, sound, particles, trails, UI, walls or obstacles, and do not change how the player moves. If my project already has any of these, leave them exactly as they are.

The feel depends on these, so keep them exactly:
- A steady rhythm: walk, stop, turn, walk back.
- It never leaves its line, whatever the player does.

Before you finish, check your work:
- Does it walk a straight line 6 body lengths long through where it started?
- Does it wait 1 second at each end and ignore the player?
- Does every number come from my project or the fallback above, with nothing left for me to set?
- Does it behave the same at 30 and 144 frames per second?
- Does the project run with no errors or warnings in my engine version, as soon as I start the game, with no extra setup?
- Did you add nothing beyond what is described?

Works with any AI coding tool. Paste it into your project and run.

3

Wander

Drifts around in lazy curves, never far from home.

prompt.txt3,500 chars
Wander: Drifts around in lazy curves, never far from home.

Goal: Make my enemy wander with Wander steering, so it feels aimless and alive: it drifts in smooth, changing curves and never strays far from home.

Use what my project already has:
- The player and the enemy. If either is missing, add a placeholder: one plain solid-colored square or circle, made with my engine's most basic built-in shape or sprite object. A placeholder player moves with WASD or the arrow keys at a constant speed, with no acceleration.
- If you add a placeholder player, put it a quarter of the way across the screen from the left, halfway down. If you add a placeholder enemy, put it 80% of the way across and 30% of the way down.
- Take every speed, distance and size from what my game already uses: the enemy's move speed and size, the player's speed. If there are no such values, make the player cross the screen in 2.5 seconds, set the enemy's speed to 90% of the player's, and size characters at 1/16 of the screen height.

Behavior. The pseudocode below is the exact behavior. Translate it line by line into my engine's language; keep every number, and do not add, remove, reorder or smooth anything:

    at start:
      home = enemy.pos
      heading = random angle (radians)
      turnRate = 0; nextChange = 0
    
    every frame:
      nextChange -= dt
      if nextChange <= 0:
        turnRate = random between -90 and 90         # degrees per second
        nextChange = random between 0.5 and 1.0      # seconds
      if length(enemy.pos - home) > 4 * body:
        turn heading toward the direction of home, at most 180 degrees per second
      else:
        heading += radians(turnRate) * dt
      enemy.pos += (cos(heading), sin(heading)) * 0.5 * speed * dt   # never stops

In the pseudocode:
- pos is a center position on the play plane (the ground plane in 3D). body is the enemy's body length, its larger side. speed is the enemy's move speed. dt is this frame's delta time in seconds.
- normalize of a zero vector is the zero vector. perpendicular(v) is v turned 90 degrees on the play plane.
- "pos += x" means move by x this frame. If my project moves characters through physics or its own movement code, make the same move through that (velocity = x / dt) instead of setting the position directly, so walls still stop it.

Edge cases:
- Frame-rate independent: scale every movement and every timer by the frame's delta time.
- Works in 2D and 3D. In 3D, move on the ground plane.
- The enemy has no physical collision with the player: it never pushes, blocks or knocks back the player, and the two can overlap.
- Add only what is described here. No health, damage, knockback, sound, particles, trails, UI, walls or obstacles, and do not change how the player moves. If my project already has any of these, leave them exactly as they are.

The feel depends on these, so keep them exactly:
- Always moving, in smooth curves that keep changing.
- It drifts back toward home instead of leaving.

Before you finish, check your work:
- Does it keep moving in smooth curves, with no stops and no sharp turns?
- Does it stay within about 4 body lengths of where it started?
- Does every number come from my project or the fallback above, with nothing left for me to set?
- Does it behave the same at 30 and 144 frames per second?
- Does the project run with no errors or warnings in my engine version, as soon as I start the game, with no extra setup?
- Did you add nothing beyond what is described?

Works with any AI coding tool. Paste it into your project and run.

4

Random patrol points

Picks a random spot, walks there, pauses, repeats.

prompt.txt3,644 chars
Random patrol points: Picks a random spot, walks there, pauses, repeats.

Goal: Make my enemy patrol random points around its home, so it feels restless and hard to predict: it walks straight to a random spot, pauses, then picks another.

Use what my project already has:
- The player and the enemy. If either is missing, add a placeholder: one plain solid-colored square or circle, made with my engine's most basic built-in shape or sprite object. A placeholder player moves with WASD or the arrow keys at a constant speed, with no acceleration.
- If you add a placeholder player, put it a quarter of the way across the screen from the left, halfway down. If you add a placeholder enemy, put it 80% of the way across and 30% of the way down.
- Take every speed, distance and size from what my game already uses: the enemy's move speed and size, the player's speed. If there are no such values, make the player cross the screen in 2.5 seconds, set the enemy's speed to 90% of the player's, and size characters at 1/16 of the screen height.

Behavior. The pseudocode below is the exact behavior. Translate it line by line into my engine's language; keep every number, and do not add, remove, reorder or smooth anything:

    at start:
      home = enemy.pos
      target = pickPoint(); wait = 0
    
    pickPoint():
      repeat:
        p = home + (random direction) * (random between 0 and 4) * body
      until length(p - enemy.pos) >= 2 * body         # far enough to be a real walk
      return p
    
    every frame:
      if wait > 0:
        wait -= dt
        if wait <= 0: target = pickPoint()
        return                                       # stands still while it pauses
      toTarget = target - enemy.pos
      step = 0.6 * speed * dt
      if length(toTarget) <= step:
        enemy.pos = target
        wait = 1.5
      else:
        enemy.pos += normalize(toTarget) * step       # straight line

In the pseudocode:
- pos is a center position on the play plane (the ground plane in 3D). body is the enemy's body length, its larger side. speed is the enemy's move speed. dt is this frame's delta time in seconds.
- normalize of a zero vector is the zero vector. perpendicular(v) is v turned 90 degrees on the play plane.
- "pos += x" means move by x this frame. If my project moves characters through physics or its own movement code, make the same move through that (velocity = x / dt) instead of setting the position directly, so walls still stop it.

Edge cases:
- Frame-rate independent: scale every movement and every timer by the frame's delta time.
- Works in 2D and 3D. In 3D, move on the ground plane.
- The enemy has no physical collision with the player: it never pushes, blocks or knocks back the player, and the two can overlap.
- Add only what is described here. No health, damage, knockback, sound, particles, trails, UI, walls or obstacles, and do not change how the player moves. If my project already has any of these, leave them exactly as they are.

The feel depends on these, so keep them exactly:
- Straight walks to new spots, each one different.
- A clear pause before it picks the next spot.

Before you finish, check your work:
- Does it walk in straight lines to random spots within 4 body lengths of home?
- Does it pause 1.5 seconds at each spot and ignore the player?
- Does every number come from my project or the fallback above, with nothing left for me to set?
- Does it behave the same at 30 and 144 frames per second?
- Does the project run with no errors or warnings in my engine version, as soon as I start the game, with no extra setup?
- Did you add nothing beyond what is described?

Works with any AI coding tool. Paste it into your project and run.

5

Guard post

Holds its post and steps out only to meet you.

prompt.txt3,657 chars
Guard post: Holds its post and steps out only to meet you.

Goal: Make my enemy guard its post on a leash, so it feels territorial: it stands still until the player comes close, steps out to meet them, but never strays far, and walks back when they leave.

Use what my project already has:
- The player and the enemy. If either is missing, add a placeholder: one plain solid-colored square or circle, made with my engine's most basic built-in shape or sprite object. A placeholder player moves with WASD or the arrow keys at a constant speed, with no acceleration.
- If you add a placeholder player, put it a quarter of the way across the screen from the left, halfway down. If you add a placeholder enemy, put it 80% of the way across and 30% of the way down.
- Take every speed, distance and size from what my game already uses: the enemy's move speed and size, the player's speed. If there are no such values, make the player cross the screen in 2.5 seconds, set the enemy's speed to 90% of the player's, and size characters at 1/16 of the screen height.

Behavior. The pseudocode below is the exact behavior. Translate it line by line into my engine's language; keep every number, and do not add, remove, reorder or smooth anything:

    at start:
      post = enemy.pos
    
    every frame:
      toPlayer = player.pos - post
      if length(toPlayer) < 5 * body:                # the player is in its territory
        reach = min(length(toPlayer) - body, 4 * body)   # stop one body short, leash of 4 bodies
        goal = post + normalize(toPlayer) * max(reach, 0)
        v = speed
      else:
        goal = post                                  # go home
        v = 0.6 * speed
      toGoal = goal - enemy.pos
      if length(toGoal) <= v * dt:
        enemy.pos = goal                             # stands still once there
      else:
        enemy.pos += normalize(toGoal) * v * dt

In the pseudocode:
- pos is a center position on the play plane (the ground plane in 3D). body is the enemy's body length, its larger side. speed is the enemy's move speed. dt is this frame's delta time in seconds.
- normalize of a zero vector is the zero vector. perpendicular(v) is v turned 90 degrees on the play plane.
- "pos += x" means move by x this frame. If my project moves characters through physics or its own movement code, make the same move through that (velocity = x / dt) instead of setting the position directly, so walls still stop it.

Edge cases:
- Frame-rate independent: scale every movement and every timer by the frame's delta time.
- Works in 2D and 3D. In 3D, move on the ground plane.
- The enemy has no physical collision with the player: it never pushes, blocks or knocks back the player, and the two can overlap.
- Add only what is described here. No health, damage, knockback, sound, particles, trails, UI, walls or obstacles, and do not change how the player moves. If my project already has any of these, leave them exactly as they are.

The feel depends on these, so keep them exactly:
- Perfectly still while the player is away.
- It steps out fast, then walks back slowly when the player leaves.

Before you finish, check your work:
- Does it stand still at its post until the player is within 5 body lengths?
- Does it stay within 4 body lengths of the post and walk back when the player leaves?
- Does every number come from my project or the fallback above, with nothing left for me to set?
- Does it behave the same at 30 and 144 frames per second?
- Does the project run with no errors or warnings in my engine version, as soon as I start the game, with no extra setup?
- Did you add nothing beyond what is described?

Works with any AI coding tool. Paste it into your project and run.

6

Patrol and chase

Patrols until it spots you, chases, then gives up and goes back.

prompt.txt4,049 chars
Patrol and chase: Patrols until it spots you, chases, then gives up and goes back.

Goal: Make my enemy patrol, chase the player when it spots them, and give up and return when they leave its area, so it feels watchful: calm on its route, sharp when it sees you.

Use what my project already has:
- The player and the enemy. If either is missing, add a placeholder: one plain solid-colored square or circle, made with my engine's most basic built-in shape or sprite object. A placeholder player moves with WASD or the arrow keys at a constant speed, with no acceleration.
- If you add a placeholder player, put it a quarter of the way across the screen from the left, halfway down. If you add a placeholder enemy, put it 80% of the way across and 30% of the way down.
- Take every speed, distance and size from what my game already uses: the enemy's move speed and size, the player's speed. If there are no such values, make the player cross the screen in 2.5 seconds, set the enemy's speed to 90% of the player's, and size characters at 1/16 of the screen height.

Behavior. The pseudocode below is the exact behavior. Translate it line by line into my engine's language; keep every number, and do not add, remove, reorder or smooth anything:

    at start:
      home = enemy.pos
      ends = [home + (-3, 0) * body, home + (3, 0) * body]
      state = PATROL; i = 1; wait = 0
    
    every frame:
      dist = length(player.pos - enemy.pos)
      if state == PATROL:
        if dist < 5 * body: state = CHASE            # spotted
        else if wait > 0: wait -= dt                 # paused at an end
        else if walkTo(ends[i], 0.6 * speed): i = 1 - i; wait = 1.0
      if state == CHASE:
        if length(player.pos - home) > 8 * body: state = RETURN   # they left its area
        else if dist > body: walkTo(player.pos, speed)   # stops one body short
      if state == RETURN:
        i = index of the end nearer to enemy.pos
        if walkTo(ends[i], 0.6 * speed): state = PATROL; i = 1 - i; wait = 1.0
    
    walkTo(goal, v):                                 # true on arrival
      toGoal = goal - enemy.pos
      if length(toGoal) <= v * dt: enemy.pos = goal; return true
      enemy.pos += normalize(toGoal) * v * dt; return false

In the pseudocode:
- pos is a center position on the play plane (the ground plane in 3D). body is the enemy's body length, its larger side. speed is the enemy's move speed. dt is this frame's delta time in seconds.
- normalize of a zero vector is the zero vector. perpendicular(v) is v turned 90 degrees on the play plane.
- "pos += x" means move by x this frame. If my project moves characters through physics or its own movement code, make the same move through that (velocity = x / dt) instead of setting the position directly, so walls still stop it.

Edge cases:
- Frame-rate independent: scale every movement and every timer by the frame's delta time.
- Works in 2D and 3D. In 3D, move on the ground plane.
- The enemy has no physical collision with the player: it never pushes, blocks or knocks back the player, and the two can overlap.
- Add only what is described here. No health, damage, knockback, sound, particles, trails, UI, walls or obstacles, and do not change how the player moves. If my project already has any of these, leave them exactly as they are.

The feel depends on these, so keep them exactly:
- A calm walk on its line until the player comes near.
- A sudden switch to full speed, then a slow walk back to its route.

Before you finish, check your work:
- Does it patrol its 6-body line, chase within 5 body lengths, and give up once the player is 8 body lengths from home?
- Does it walk back to the nearer end of its line and patrol again?
- Does every number come from my project or the fallback above, with nothing left for me to set?
- Does it behave the same at 30 and 144 frames per second?
- Does the project run with no errors or warnings in my engine version, as soon as I start the game, with no extra setup?
- Did you add nothing beyond what is described?

Works with any AI coding tool. Paste it into your project and run.

More sets

Back to @promptcollections on Instagram
Prompt copied. Paste it into your AI tool.