llms.txt: machine-readable documentation index. Markdown version of this page is also available.

Ninja Bear Studio Plugins Help

Use Faction Attitude in AI Decisions

Make a guard greet a friendly target and chase a hostile one. Start with a guard whose AI Controller already runs a tree and has a target actor. The target can come from perception or from a reference you supply for testing. For perception through Ninja Bot, see Bot and Factions.

Behavior Tree

Choose a branch using the Blackboard

  1. In the Blackboard, add Target (Object, base class Actor), TeamID (Int), FactionName (Name), and Alignment (Enum, ETeamAttitude). Have the controller write the current target to Target.

  2. Attach the Faction Data service to the selector that contains both reactions. Set Faction Member Key to Target. Map the three output keys to TeamID, FactionName, and Alignment. Attitude Towards Agent Key holds the guard's attitude toward the target.

  3. Add a Check Attitude decorator to the chase branch. Select Alignment as its Attitude Key and Hostile as its Attitude Test. Add another to the greeting branch and choose Friendly. Require a valid Target on both branches and leave a patrol or wait branch for other cases.

Faction Data service writing the target's team, faction name, and alignment
Check Attitude decorator testing a Blackboard key

State Tree

Choose a state using the target actor

  1. Run the State Tree on the guard's controller and expose the current target actor for binding. On the chase state's Enter Conditions, add Check Attitude, bind Target to that actor, and set Attitude Test to Hostile. The condition asks how the controller sees that actor.

  2. Give the greeting state its own Check Attitude condition set to Friendly. Leave a patrol or wait state available when neither condition passes. Arrange for the tree to select a state again when you change targets.

  3. If a task also needs the target's team ID or faction tag, add the Faction Data evaluator and bind its Faction Member to the target. Tasks can then read its outputs. The enter condition only needs the target actor.

Faction Data evaluator with a member input and team, faction, and attitude outputs

Try It in Play

With Simple Attitude Check, configure the guard's faction as Friendly toward itself and Hostile toward other factions. Give it an ally as the target, then an outsider. Expect the greeting branch for the ally and the chase branch for the outsider. Clear the target and confirm the guard can resume its patrol. If the wrong branch runs, print Get Attitude with the guard as Source and the current target as Target, then compare it with the value the tree uses.

25 November 2026