Hey guys, im following a Udemy course which is covering AI. I’ve setup the AI character and controller and selected the controller insude the character.
When the AI character sees me in the level, the green perception updated sphere pops up. However, the AI character does not update to handle this.
As you can see, I cast to my character, but no matter where i put the print string, even right after that event node, it does not fire.
I feel like I’ve missed a step. It works fine on the course video, but people often do things off camera and don’t say anything.
Can you guys suggest anything i msy have missed?
Much appreciated.
dont lose your patience with the tutorial, this is actually the most important lesson it will teach (how to troubleshoot).
take your time and work through this logically and you’ll be setup for success in the future.
So the first thing is to take stock of what do we know?
We know that the cast node is not evaluated because neither branch fires. It should also be true then that if you put a breakpoint on the On Target Perception Updated event node that will not break either. Redundant but I always like to double check everything just in case there is something about the engine that I don’t know yet.
My next step would be just to starting working backwards. This event doesn’t fire… who calls this event? You can select the event node and press CTRL F to search all its references within the blueprint. But look for the binocular icon to search where this event is referenced in all blueprints. Now you’ll be able to see all the places it is called.
You can then just keep working backward doing the same pattern. Print strings or break points to find the point of failure. Once you’ve found that, if it is not obvious what the problem is, share what you’ve learned and somebody here will be able to help.
@BIGTIMEMASTER 's advice is VERY good, but I’m pretty positive this is an engine event which will complicate things a bit. So you’ll need to search the docs for details on the inner workings. I found this:
I think this could be either that you don’t have the AIPerception to use the right sense or possibly that you don’t have an AI Stimuli Component on your player pawn with Sight set up on it (I’m assuming the Sight is the sense you are dealing with now, but they all kinda work the same).
If that doesn’t help I’ll need more info to help diagnose the issue, sorry^^;
The event is supposed to fire when the AI character sees my character. It doesn’t find any references with the magnifying glass or the binos.
So in the level, the green sphere appears when he sees me, yet the event node that that green sphere is supposed to trigger does not fire. Ive done this process a bunch of times and never had this happen.
Oh OK I see it. There are no options to setup specific stimuli (sight, hearing, etc) on the AIPerceptionStimuliSource component, but I ticked “Auto register as source” and now it works.
Both if you actually contributed to me thinking to look there. So I’m really glad I posted here.
i didn’t know that this is a c++ derived function thats part of the perception system. Sounds like mclark has a better idea about why it might not be firing.
But… the typical thing I’d try next is:
if you had a working version, go back to that and compare against the problem (you probably aren’t using version control for a tutorial, but in future if you are, it helps a lot for this sort of issue)
if you don’t have a working version right now, make a new actor and rebuild just the minimal functionality needed to get that one broken thing to work correctly. Then you have something you can compare the problem against.
hey do you have the problem i had that when i click the auto register as source if i drag and drop the object that had the stimuli source into the game while its playing it crashes
Ok bit of a dead post but was following the Quickstart Tutorial and ended up in a similar situation with the event not firing. Double checked all things listed above to no avail. Pressed ’ key to open up AI debugging and 4 and 5 on the numpad to open up ai visualization and could see the perception system viewing my character. Was stumped for a bit but tried shutting down UE and opening it up again and it worked. Hopefully this helps anyone else that finds their way here.
Little easy thing to miss is the ‘Detect by affiliation’ check boxes in the Perception component. This was a problem for me when I wanted the AI to detect something other than enemies.
You have to do this
Inside you AI Perception actor component, look at the details panel. There should be a panel called Detect by affiliation deep inside the Senses config array. Turn all the checkboxes on inside of Detect by affiliation