I managed to add some C++ code and the project compiles, but it doesn’t work as expected. The AI still detects my character from the chest. When i try to buid I get errors related to AutomationTool (Microsoft.Build.Evaluation).
I’m very new to C++, so I’m probably missing something or doing it wrong.
Could someone explain what I need to change (or what I should check) to make AI Sight use a head socket instead of the actor center?
you can use the “preformated text” system to post code more directly then pictures. it saves having to make pictures, and it saves readers needing to look at pictures to read raw text.
if you are getting errors in your build then only your last stable C++ build will be used, and if you haven’t had any stable C++ builds then the base engine behavior will be used. if the error doesn’t point to any of your C++ files, the resulting .gen files of your C++, or an engine file then the problem is with how your IDE is setup.
most of the build errors outside of C++ syntax things will be
linker LNK 2019 or LNK 2001 these are mostly either missing a function body, or an expected function declaration for things like interfaces
a wall of text about a type not be understood by a collection (this is mostly either missing an include or a spelling issue
some flavor of ‘unknown type int assumed’ missing include or forward declaration
if you can include the error we might be able to help you narrow it down further.
all Bone and socket names are Exact and should be searched with either an FName(TEXT("")) or just TEXT(""), so you might have a name mismatch issue from using a cString instead of piping it into a TEXT() macro, and when the engine does real time string compares most of them will silently fail for “close”. depending on what the string compare is looking for you might get a warning message in the output log.
the “easy” answer is to give each mesh these entities will perceive a Socket, your choice if the socket is placed at the top of the head, at the base of the head, or somewhere in between depending on how “generous” you want to be to the player or the NPC
you can hand that location to the perception system to look for
OtherActor -> GetSkeletalMesh ->GetSocketLocation(TEXT("SocketName")); // the name should be exactly the same as entered into the SkeletalMesh editor
then do a line trace from the “perceiver’s” head or eyes, to the OtherActor’s “Head_Socket” if the line trace is obstructed then they didn’t “see” the target
keep in mind that Seeing the center of the body should probably also be a positive detection, and the Head should be a last resort.
if your game has overhanging objects that could occlude the head, but not the body. Even if it is just a diagonal surface that makes an acute angle to the ground. or a floating thing
Heck if your game has entities at higher elevations and a doorway/arch the potential target could be maybe a fraction of an inch inside the door and be “undetected”
the 2 red characters (left) would be “invisible” if the detection is based solely on the “head”
hi, thank you for taking time to write this, I really appreciate it.
Your explanation about why the perception system uses the capsule center as a stable reference made things much clearer for me. I didn’t realize how much changing that could affect the overall behavior.
I’m going to rethink my approach and separate perception from the aiming logic like you suggested.