Title: NPC AI StateTree logic: Guard not responding or attacking empty air (GAS + C++ Architecture)

Title: NPC AI StateTree logic: Guard not responding or attacking empty air (GAS + C++ Architecture)

Hi everyone,

I’m working on a Guard AI system in Unreal Engine 5.8 using StateTrees, AI Perception, and the Gameplay Ability System (GAS). I’ve successfully set up the foundation in C++, but I’m hitting some logic traps in the StateTree behavior (Pictures below might help if needed).

The Current Setup:

  • Base Class: C++ AMyCharacterBase
  • (implements IAbilitySystemInterface)
  • Perception: BaseGuardAIController using Hearing and Sight.
  • StateTree workflow: Idle → MoveToNoise → Inspect → Attack → ReturnToPost.
  • Combat: Custom StateTree Task
  • BTT_ActivateAbility that triggers a GAS GA_MeleeAttack.

The Problem:

  1. The Guard reaches the noise location just fine, but it just stands there after it has reached the location, not attacking as it should. It should be attacking after it reaches the location, even if the player isn’t there (attacking the air).
  2. The transitions between “Inspecting” and “Combat” don’t seem to trigger reliably when the player is actually seen or when it reaches the location.
  3. I’m struggling with the logic flow to make the Guard return to his starting position only after the target is dead or lost.

What I’ve Tried:

  • Verified NavMesh is active.
  • Checked PossessedByin C++ to ensure StartLogic() is called.
  • Increased AcceptableRadius to 50.0

I’ve attached screenshots of my StateTree graph and parameters. Any advice on how to better structure these transitions or handle the TargetActor Logic would be greatly appreciate!