DEV Community

Lucas
Lucas

Posted on Fully Autonomous

When Should a Companion Get Out of the Player's Way?

Imagine a companion examining a shelf. You walk past, and they immediately shuffle away. You turn back to look at them, and they retreat again.

The collision system may be doing its job. The performance is harder to read. Did the character finish examining the shelf, become nervous, or simply detect your capsule?

Companion movement needs a decision about who can use a space and under what conditions. That decision can become part of the character's performance, especially when the player approaches them.

A useful detail from Ellie's implementation

In Game AI Pro 2, Naughty Dog programmer Max Dyckhoff describes several choices behind Ellie's movement in The Last of Us:

  • Follow-position evaluation considered staying on the same side of the leader and avoiding positions in front of the player. Movement filters reduced unnecessary short trips.
  • A stationary buddy did not automatically retreat when the player approached. The team delayed the dodge, using an authored animation and a vocal reaction if the player continued toward her.
  • An early cover behavior made the buddy leave when the player approached. The replacement allowed Joel and the buddy to share cover through a dedicated animation set while preserving the player's normal movement and shooting actions.

These are implementation choices described by their developer, rather than measurements showing that one movement policy universally produces a more appealing companion. The particularly useful production detail is the shared-cover animation: the team supported both characters occupying that situation instead of always displacing one of them. Dyckhoff, Chapter 35, sections 35.3.1–35.3.3 and 35.4.2

What local avoidance can decide

Epic's navigation documentation describes RVO avoidance as choosing a velocity that avoids nearby agents while remaining close to the agent's preferred velocity. It also documents a concrete limitation: Unreal's RVO implementation does not use the navigation mesh for avoidance, so an agent can be pushed outside its bounds. Epic Games, Using Avoidance With the Navigation System

For the experiment below, assign separate responsibilities. The character policy chooses whether to stay, move aside, or enter a supported shared interaction. Navigation and collision handle whether that choice can be executed safely. A target that looks socially appropriate still needs a reachable route, sufficient clearance, and an interruption path.

A graybox experiment: proximity versus passage

The following is a proposed design experiment, not a reconstruction of Naughty Dog's system or a completed playtest.

Build one room with a companion, a shelf, a doorway, and a wide alcove. Start with capsules and identical locomotion in every condition. Keep dialogue disabled so a funny line cannot hide a movement problem.

This experiment targets a cooperative companion meant to remain close. A deliberately skittish character could use proximity-based retreat as part of its performance.

Compare two policies:

A. Proximity yield. The companion chooses a clear retreat point whenever the player enters a fixed radius. Keep the radius visible in the debug view.

B. Passage yield. The companion can remain near the player. It moves aside when the player's projected movement would intersect its occupied space, or when it obstructs an interaction zone that the player is approaching or trying to use, such as the exit.

For an initial implementation of B, project the player's displacement using the controller's velocity, movement input, and acceleration, then sweep the player's collision shape along that projected path. A horizon such as half a second is an experiment setting, not a recommended universal constant. Draw the sweep and the proposed retreat point so a designer can inspect why the character moved.

Only accept a retreat point if the path to it and the final occupied space are clear. Check the full body clearance needed by the movement, not just whether a point lies on the navigation surface. Once the retreat starts, retain its destination unless it becomes unsafe; repeatedly switching sides can create a new obstruction.

The initial hypothesis is narrow: B should reduce retreats during harmless close passes without increasing blocked passages. Whether that also makes the companion seem more deliberate needs a separate observation.

Use the same routes in both conditions

Record a companion-free reference run for each case below, then replay its input sequence through A and B from the same starting positions:

  1. Walk past the companion without intersecting its body.
  2. Walk directly toward it at normal speed.
  3. Sprint toward it, then reverse direction.
  4. Stop in the doorway while the companion is moving aside.
  5. Approach the shelf from each side, including while the companion is already using it.

The reversal matters. A prediction based on current input becomes wrong as soon as the player changes their mind. The doorway stop checks a different failure: a valid retreat can become invalid because its destination is now occupied.

Log three things for each run:

Observation What it helps distinguish
Retreats during a replay whose player route would have cleared the stationary companion Unnecessary yielding
Time the companion prevents commanded player movement, checked against the companion-free replay The cost of yielding too late or choosing the wrong destination
Retreats abandoned or redirected before completion Unstable decisions or changing geometry

For the first measure, compare the reference route with the companion's footprint before its retreat. A route recorded with the companion present may already contain evasive steering. Likewise, a lack of collisions after the companion moves cannot establish that the retreat was unnecessary. Reset each case before comparing policies, and exclude obstruction caused by walls or other objects.

Review obstruction clips individually. A collision-free run can still feel bad if the companion repeatedly crosses the camera or makes the player steer around it. Record those events separately rather than hiding them inside a single success score.

Add one place they can share

After the passage policy works, give the wide alcove one authored two-character arrangement. The player might inspect a map while the companion stands beside it. Define both footprints, the entry routes, and the exits. Reject the arrangement if either actor cannot reach their place without crossing the other's occupied space.

Start this interaction through an explicit player input. That keeps walking near the companion from unexpectedly taking over the player's movement. Let the player leave immediately through a tested exit transition, and have the companion release the shared arrangement when they do.

This is a separate comparison. Add the shared interaction to B, then check whether players can enter, leave, and return without the companion being displaced into the doorway. Only after that should animation work add a glance, a turn of the shoulders, or a small adjustment that acknowledges the other character.

In a separate free-play session, ask players what they thought the companion was doing before offering labels such as “considerate” or “confident.” If they describe the movement as random, inspect the clip where that interpretation began. The geometry logs can identify a functional improvement; they cannot establish the character's personality by themselves.

Where this approach needs a different rule

A narrow passage may have no valid retreat point. In that case, give the companion a waiting position outside the bottleneck before the player arrives. If the level offers neither a passing place nor a shared arrangement, changing the avoidance radius will not create one.

Combat also changes the cost of holding a position. A companion should not remain planted to preserve an animation while preventing an escape. Keep urgent clearance available as an override, and test it at the player's fastest supported movement speed.

The useful question for an animation review is specific: what changed in the available space that made this character move? If the answer is visible in the scene, a small adjustment has a chance to read as a choice. If the answer exists only inside a proximity trigger, inspect the movement policy before adding another reaction animation.


AI assistance disclosure: AI was used to research the linked primary sources, structure and draft this article, and check its wording against those sources. The proposed experiment has not been run; no playtest results or personal development experience are claimed.

Top comments (0)