Vixen
dd8b0a81
csharp
public struct AiFocus

What an agent is paying attention to.

Read the guide page for this →

Remarks

Unreal's focus, and its value is that everything downstream reads one place. A rotation task, an aim offset, a head-look constraint and a dialogue camera all want "what is this character looking at", and without a component for it each of them takes its own blackboard key and they disagree the first time one branch sets a key another does not.

⚠ An entity or a point, and the entity wins. A focus on an entity follows it as it moves; a focus on a point does not. Two fields rather than a discriminated one because Null already means "there is no entity", so the tag would be a second copy of a fact the value carries.

⚠ [Component] without [DataContract], and it carried both until #1056. Target is an Entity, and an entity id is a dense, reused slot in one running process — written into a .vxscene or a captured world it names a different entity on the way back, or nothing at all, and neither failure says so. CameraTargets, Possessing, PossessedBy, ViewTarget and PredictionSmoothing all keep the same rule for the same reason; VXS0416 is that convention with a compiler behind it, and this type is the one it found that had drifted out of it. A focus that has to survive a save has nothing to hold instead until there is a persistent entity identity — #296. A focus is a decision the tree makes each time it runs, so losing it across a load is the correct outcome anyway.

Fields and properties (3)

  • public Entity Target

    What it is looking at, or Null for Point.

  • public Vector3 Point

    Where it is looking, when there is no target.

  • public bool HasFocus

    Whether it is looking at anything at all.

Methods (3)

  • public readonly bool TryResolve(World world, out Vector3 position)

    Where the focus is now, following the target if there is one.

  • public static AiFocus On(Entity target)

    A focus on an entity.

  • public static AiFocus At(Vector3 point)

    A focus on a place.

Used by (6)

  • AgentTargetVixen.Ai.Nodes
  • DefaultFocusServiceVixen.Ai.Nodes
  • FocusTestsVixen.Ai.Nodes.Tests
  • RotateTowardTestsVixen.Ai.Nodes.Tests
  • SceneComponentTestsVixen.Ai.Nodes.Tests
  • TypeRegistrationVixen.Ai.Nodes