Skip to lesson
LESSON 18 / 44 · Intermediate

Enemy detection and line of sight

Control when an enemy notices a player.

Open editor in a new tab ↗

Before you begin

Use an enemy with saved Sprite Studio artwork and enabled enemy behavior.

Build it step by step

  1. Open Configure enemy and choose Wait, then chase so the enemy can reveal the effect of detection.

  2. Set Notice the player within (pixels) to 220 and Reaction time to 0.4 as a starting experiment.

  3. Enable Walls block detection and attacks. Put a solid wall between the enemy and a player whose kind is Player.

  4. Press Play. Approach outside the range, then move inside it. Compare the response with and without the wall blocking the path.

  5. Adjust range and reaction time until the player gets a fair warning. Keep the rest of the settings unchanged for each comparison.

TRY THIS IDEA

Practical example

A guard can watch a corridor but fail to see a player behind a wall. A longer reaction time gives the player a chance to retreat.

Test your work

The enemy reacts within its range and respects the wall option.

If it does not work

Check that the target is a living Player, not merely an object named Player. The controller chooses the nearest eligible player; it is not a general pathfinding system.

MAKE IT YOUR OWN

Student challenge

Create a safe hiding spot and measure how close the player can get before detection.

Show the result to a partner. Explain what you changed and how you tested it.

Keep exploring