Search After Losing a Target

Goal

Use this pattern to keep searching for a short time after sight is lost, then return to normal behavior.

Tree structure

A Selector chooses Chase, Search at the last known position, or Patrol.

How it runs

Place Chase first, Search second, and Patrol last. Store the target’s last known position in a Shared Variable while the target is visible. Set the Chase Sequence’s Abort Type to Both so losing sight stops Chase, while seeing the target again interrupts Search or Patrol immediately.

After sight is lost, the Selector enters Search and moves the agent to the stored position.

Can See Target has failed, so the Search branch waits at the last known position while Patrol remains inactive.

The highlighted path shows the tree searching after the Chase branch has stopped. Clear the stored position when the search finishes so Patrol becomes the fallback.

Selector, Sequence, Shared Variables, and conditional aborts are built in. The perception and last-known-position tasks are specific to your game, while movement, searching, and patrolling can use your own actions or tasks supplied by a movement integration.

Variations

Keep Search finite with a Wait, repeat count, or timeout. Add several search points when the movement system can generate a local investigation pattern.

Tasks used in this tree

Selector, Sequence, Wait in the Actions reference, and Conditional Aborts.