Using AI perception sight to target head in UE5.3

Slavian2003
Tue, 13 Feb 2024 13:02:47 +0000
AI

Hello. I’m making third person game and have a problem with AI Perception in UE5.3. AI Perception Sight targets the center of the body of my character and I need it to use head of my character as the target.

So, I made research and found out that the only way to implement this is to use C++. My project was made with the help of blueprint only and I never used C++ before, so don’t judge me too harshly. I also find following instructions IAISightTargetInterface::CanBeSeenFrom | Unreal Engine 5.2 Documentation and used it to make a code.

First, I added to my BP_NPC_Base (this is base for all NPC character in my game) a AIPerception and set Sight as following.

Then I added to the BP_NPC_Base a parent character class in C++ named C_Character and used Visual Studio 2022 to implemented following code based on instructions mentioned above.
C_Character.h code is as follows

C_Character.cpp code is as follows

So, after that it seems that AISIghtTargetInterface was implemented as Inherent in Class Settings.

But nothing happens. The AIPerseption sight green sphere is still in the center of the torso of my character.

Did I miss something? Do you have any suggestions? I would be glad to have a piece of advice.

9 posts - 7 participants