I solved this by using the SetFocus node and setting the Player Camera Manager as the target.
EDIT: This only solves the “looking at waist issue” atleast in VR.
I solved this by using the SetFocus node and setting the Player Camera Manager as the target.
EDIT: This only solves the “looking at waist issue” atleast in VR.
This is the only solution right now. I’ve searched everywhere. Confirmed working! Thank you so much!
Agreed, this solution still works! It worked for my project. Thank you!
This really should be a setting somewhere.
How would I set this up to be callable from a blueprint? I’m pretty good with blueprint scripting, but never worked with C++. Seeing your resolution here makes me want to learn. Could you elaborate a little?
I just figured out for myself that all I needed to do was compile my project after implementing this code (making sure to let all files index in visual studio first), then I could simply replace the parent class of my AI controllers in the game with my new custom controller. Thanks for sharing this solution!
@Zarsky can you please explain this a bit further? Thanks in advance!
I did this sleezy little work-around. Instead of setting control rotation in the aicontroller, I’m handling it in the NPC character blueprint itself on an event tick. It’s not pretty, but it works. No C++ required.
For whatever reason, Set Control Rotation functions correctly in the NPC blueprint, but not the AI Controller.
This didn’t work for me in current version 5.3.2. Has something changed in the newer versions of unreal 5 that has made it so the function you need to override has changed? From what I know it should be the same/this fix should still work. It could be that I have encountered many bugs/crashes related to adding code to my project and had to revert to a backup I made before implementing this fix in order to get it to compile correctly (long story, but first time there were errors compiling, which completely bricked my project. kept saying that project was compiled with different engine version and couldn’t be built on startup. Building from source/visual studio didn’t work.) I fixed the issue and now it compiles successfully, yet reparenting AIC to new custom class still doesn’t allow for pitch rotation updating through set focal point unless it’s a pawn through “set focus” (so essentially, nothing changed.) Tried reparenting back to AIC then to custom class again didn’t work.
I did find my own hacky work around that hopefully I can replace with the correct fix (overriding the terrible default AIC UpdateControlRotation function.) All I did was parent an empty pawn (just scene root) that I called my "Head Actor) to the mesh of my character, and used an interface function that grabs the head actor to then set the focus to the head actor(pawn), not my character for better accuracy.
The IF is then called in the AIC, and the “set focus” node is used with the head actor as focus target.
Still not sure why they decided to completely disallow the use of updating pitch for focal point. If you don’t want a specific AI to use pitch, then you could just uncheck “use control rotation pitch.” If whoever requested this REALLY needed to have it not update pitch they could have had a simple boolean to check for the people that want to update pitch. But for me and a lot of people it seems to be crucial to have because I can think of 100 use cases that need it before I can think of one that doesn’t. And being stuck with just “set focus” doesn’t offer much if any flexibility.
I would like to share some of my findings in this Post.
I tried to get AI to aim at my characters head, the only node and input to that node that worked was the SetFocus node and my character reference as an input. However creating a pawn class blueprint and attaching it to my characters head solved all of my headache. The SetFocus node in the AIController liked the Pawn reference. It adjusted both Pitch and Yaw to orient and aim at my characters head where i had attached the newly created Pawn BP.
Hope this helps someone struggling to get AI to Aim correctly at the player.
As a side note it should be possible to spawn the Pawn actor from the Playercharacter or AI controller and manually reposition the AIM Pawn to designated areas where the AI can and should aim.
Is only the arm visible? Relocate the Aim Blueprint to that mesh socket location by attaching it to the mesh component in the socket name location.
Need the AI to shoot the character from different perspectives, all with their own body part that is uncovered. Let each AI spawn their own Aim location Pawns and attach it to the mesh of the player with the socket location where they can shoot the player. This trick probably requires some tracing to know which body part is not obstructed. A for each loop with break from a string/name array of socket names that inputs to a socket location node where the output as the end location for the line trace by channel node. Set them by priority and break the for each loop ones one is hit and set that socket location as the aim pawn location or attached location.
have to agree with this rant, this is extremely frustrating and the explanation leaves us wondering… just lost 2 days to this.
all those years later and we’re still not told how to handle this simple use case that must confuse thousands of devs, the whole thing does not work, unpossess/possess AI/Character. It’s not logical, it breaks everything, its a major issue if not a bug.
No, this is not a feature request. The function SetFocalPoint is broken, as illustrated in your code. It requires a Vector to work, but does not communicate that it ignores the Z value.
The workaround to this bug requires either a custom AI Controller override or that you move an invisible pawn around your game for every instance you wish for an AI Controller to SetFocalPoint.
Disheartening to see such a fundamental function of the AI Controller broken and completely ignored for almost 10 years.
yeah its a shame, I’m having to program a completely custom controller instead
I opted for using invisible Pawns, as custom C++ overrides aren’t working for me as expected. I can’t spend weeks trying to reverse Epic’s mistakes.