The idea is that the enemy will do different things, if i’m being seeing and a few seconds after I’m not being seen anymore.
However, the branch is always turning false. So technically, even though the enemy follows the player, it is returning it as not visible.
It seems you aren’t specifying which AI controller to use. If this is on your AI Controller Blueprint, you can get rid of this node and use the AI Perception component- you don’t have to use extra nodes for this, just “GetAIPerception”. If it isn’t on your AI Controller Bluperint, you need to specify an actor in this node. All of the errors I can see are caused here, with this node.
Edit: @itsgoshi Updated with more description and images!
So I did this. And while some of the red lines disappeared. I still get a not visible trigger the second the enemy sees me. This is what some of the other stuff looks like.
On Target Perception Updated returns the stimulus and actor that was observed, if you need it.
Then IsSeen will be set for anything else you may need it for in your code. Then it answers true or false from there, going into chase or search locker events!
I see you’re using “On target perception updated”. The thing is I was using that for an event where the enemy will be distracted by a thrown object. I’m assuming I can’t use it for both these events?
Also, I did what you suggested, and as soon as the ai loses sight of me, it just stands still. It is supposed to first go to the nearest locker. And if I’m not there, go to a random one.
You can, you just need multiple options. Only one event node. You can use multiple checks such as “== Class” to check if it is a thrown object class, or if it is “Character” class.
So Actor → Get class → == “Character”? → Branch, on True, run this, on false, run thrown object code. Things like that.
Okay, so there are definitely some things to fix up!
It’s chasing the player non-stop because both of the == class nodes are BP_MC (I assume that is your main character blueprint). The one leading to “GoToNoise” needs to NOT be your player character.
Also, get rid of the cast in “GoToNoise”. That’s casting with no object and will create an error.
Finally, hook up the False/false output to be the “Check Lockers”.
If sensed class == BP_MC, chase player. If not, move on.
If Sensed class == thrown object, investigate. If not, move on.
If Sensed class == Neither BP_MC or thrown object, search lockers.
Well, when it is sensing the player, it should follow the player, and re-run that first line over and over and over, every time. When it doesn’t see the player is the only time the bottle should work.
If you want it to stop chasing the player, on the first line, put a “re-triggerable delay” node after the “Visible” printstring node. On that node, you’ll put in the time it should take for the enemy to stop chasing if it doesn’t see the player.
Then you need to make an event node to do the “notvisible” line. Here’s a mock-up going off of what I had in that test project
Okay so this is what everything looks like right now for reference. I have been doing stuff offline of course.
Sorry for the hassle, I’m kind of new to programming.
Hello! It’s okay! I got to work on my menus in that time.
So many things are happening. I did add what you said. So one thing that happened is that the enemy just stops in front of doors.
When this happened I tried hiding in the nearest (I think?) locker, and somehow it gave me a game over screen.
I also saw it open a random one, but from the other side of the door.
So the errors are due to “TargetLocker” not being set.
Part of why you’re running into a lot of issues is you’re trying to do everything all at once, you need to focus on one thing at a time, get it done, and move on! It helps cut down on bugs to do things this way.
So, first we’ll tackle the door. Then the lockers.
Open your level and go to one of the doors, then press the “P” key on your keyboard. There should be a lot of green space. This is your navmesh render and shows you all of the walkable area for your AI. If there is a gap in it, that means the navmesh will not allow the AI to walk there, so look at the door frame and make sure it’s got green floor! If it does not, we now know what the problem is and we can work on tackling it!
If it DOES have green floor, either your door is too small or your character is too large, likely.
Okey! So I checked off “Can affect Navigation” To false on both the door frame and door. If the door is closed, the enemy literally just gets stuck running at the door itself in the corner