How to keep AI focus on player?

Hello all, this is my first ever post looking for help from the gods as I can not for the life of me find anything online that comes close to helping me with this issue I have.

My aim is to have an AI character perform a task, then focus and track the player (look at) on the spot for X seconds and then perform its next task.

My issue is is that it will focus on the original point that the player was in and not continue to focus/track the player as i move around.

I have attempted to try work arounds but also fail with those. Could anyone explain what I am missing?

The main workaround that I liked the idea of that fixes the tracking is to have them move towards the character. As this automatically makes them face the player. However I would want them to move slowly. But I am unsure of how to change the AI walk speed only while performing this specific task.

If anyone has answers to either of these problems it would be hugely appreciated.

Thanks for helping a noob (Also not sure if the image i try to upload will work but lets hope so)

Hi Sam, you are looking for the SetFocus node on the AIController. You will also need ClearFocus when applicable (loss of sight for example).

1 Like

Thank you so much for your reply, huge appreciation. The clear focus part has worked perfectly for the issue i was having where my AI stayed looking in that direction. Unfortunately I am unsure what you mean with the AIController. Do you mean the AIController blueprint I made to run the behavior tree? Sorry if this should be obvious. I am very new and still mostly have to follow tutorials

SetFocus is a function found in the AI Controller class. So in your screenshot, if you drag off the Owner Controller variable, you should be able to find the SetFocus function there. Per your screenshot, just replace SetFocalPoint with SetFocus

1 Like

You are a legend. I kept telling my friend that this is going to be something so simple. Thank you for your time

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.