Can't get AI Controller to focus on point. [fixed]

I’m trying to debug why my PatrollingGuards aren’t focussing on the player (spawn) point.

Things I’ve tried:

  1. Use SetFocalPoint in BeginPlay() instead of in the Behaviour Tree - No Effect.
  2. Verified my Blackboard data is correct. It is.
  3. Verified the FocusAtActor task gets executed. It does.
  4. Verified with GetFocalPoint if the focal point is correctly set. It is.

But no matter what I try, my PatrollingGuard pawn does not face me.

Next, I cloned the UnrealCourse repo from github and compiled that, first against 4.13.2 (Works without any issues) and then against 4.14.0 (build from source). Again - works without any issue.

Update:

While typing this post, I decided to look further. It turned out my Patrolling Guard never got reparented of off the TP_ThirdPersonCharacter. Reparenting the PatrollingGuard To the Character class fixxed the issue.

I don’t think we are supposed to be using TP_ThridPersonCharacter anymore, and I believe Sam renamed it to NPC Patrol Guard in one of the refectoring and reorganizing videos.

I still can’t get this to work as instructed in the video. I don’t feel comfortable downloading their github repository because that doesn’t teach me what is wrong with my file. When I set the player pawn location directly through SetFocalPoint instead of using the get black board value as vector, it works just fine. So somewhere in there that the way the blackboard key setting and getting value is wrong. But I did it step by step following Sam’s video. This is very frustrating. I’m not sure whether it’s a UE4 bug or there is something missing that wasn’t explained in the video.

Yeah, I think I missed where he renamed it (Or, maybe, I just ignored it thinking it wouldn’t be a problem :P)

As for downloading the repo - I get what you are saying but it is a nice way to compare the 2.

If you expect its the blackboard data not getting set right, you can also have the blackboard data open and look at what it says in the live play. That way you can see if it sets it correctly or not.

I printed out the value from get blackboard value as vector and it’s returning ridiculous large numbers. Meaning the memory address it’s retrieving data is not correct. Also, what I noticed is Sam has several AI behavor trees of different names in the video. The one that’s called Patrol is the the same as where it was left off when Ben left.

Hmm, Those are quite weird values yes :slight_smile:

The only thing I can suggest to do is follow the entire execution flow until the point that the value goes haywire and then see whats wrong. Sorry, I can’t think of a simple way to debug it at this point.

You can probably use the Breakpoints in blueprint to find where things start to go wrong though. If you right-click a node, you can select “Toggle breakpoint” and then it’ll pause the game and jump to the blueprint when that node gets executed.

Don’t forget about binary searching :wink:

Had to completely rewatch the video without looking at my UE4 screen and realized that I didn’t set the default value of EnemyKey.

For what it’s worth, I ended up having this same problem - but in my case the solution was this:

I had a step in my patrol route where the guard would rotate to face the next waypoint before walking to it. Removing that step in the route fixed it such that the guard is always trained on the correct point.

Having the same problem, looked through all test cases. @DanM a little help here :no_mouth:

Running the game without any other BehaviourTree tasks shows that the task node is run through, and even though I finish its execution on the node it doesn’t focus on the player.

Also switched the player from the Network starting location generated actor to an actor placed in the level, auto possessed by the player.

Repo?

Updated, check it out.

@DanM heads ups?

I guess the problem is with the EnemyKey default but is there a better way to avoid this bug?
(Solved)

Anyone else still having an issue with this? In 4.18, I can’t even get the AI to turn to my Player on just the basics

image

Really frustrating =/

I did in the 4.18 and works fine, the only thing different is the component “Get AI Controller” that don’t have the execution node anymore.

Can you show the new Task and the NPC_AI?

Hey,

I had issue on 4.18 (although unrelated to the engine version), turned out in NPC_AI_BP, when you click on “Enemy Key” there’s default value that needs to be set to “Enemy” (by default it’s None). After that stuff worked. I know it’s late, but who knows maybe it’s gonna help some.

Edit: scratch that, this method breaks in 249. Control Rotation for Aim, so I’m guessing it isn’t really the answer. No idea what the actual problem is, I’d guess I messed up something with the blends, locomotion, or the massive refactor ¯\(ツ)



I’m just replying here in case anyone else gets stuck with the problem @Big_Zee had (SetFocalPoint does nothing, even when setting explicitly on BeginPlay).

I had to open my NPC Blueprint, and tick the “Use Controller Rotation” boxes under “Pawn”:

This property gets mentioned in the next video, which made me realise it was turned off by default in my BP.

Try enabling Start with Tick Enabled in the NPC_AI bp. It probably won’t update without it. In Controller category enable Attach to Pawn. And in the Ue4ASP_Character_BP (or whatever you’ve called it) under Character Movement(RotationSettings) check Use Controller Desired Rotation. I think it should work then.

Got Same Problem. and the only way i found to fix is use “Set Focal Point” or “Set Focus” connected to the tick. while in the Task i just update the value for the “aimed object or Vector” . in UE4 version previous than 4.14 this trick is not necessary. so i not know if this is a bug or they redefine the use of the method! but I will be happy if someone have an answer !

Hi , i fix the probleme for me by enable tick on Ai controller.

Privacy & Terms