Hello! Struggling with AIPerception, being chased and hiding in lockers

Hello! I would love for some help and guidance on this problem.
So I’m currently working on a horror project and I’m using the AIPerception system.
So first of all, the patrol code is just not working. After the enemy loses the player completely, they’re supposed to just move around the map. I don’t know what the problem is here.

The follow player code works-ish, however there are problems in tandem with the two next blueprints.

When it comes to checking the nearest locker. The enemy just doesn’t do it. It might follow me to the closet, and if the player is just slow enough to get in, open that very same locker, and kill the character. However, it doesn’t do that if it has lost sight of us. That’s what I kind of want to implement. Like if I run around a corner, the enemy checks the first locker that they see, and then a random one.

This brings me to the next problem. It doesn’t check a random one. It checks the same ones all the time. I just don’t get it. What can I do here? :sob:

The idea is this, I’m being chased, and get out of the enemies sight. They’re still following me but don’t know which locker I went into. First I want them to check the nearest one, and then a random one in the area. Then they should start patrolling again. But that just doesn’t happen. He literally just stands there. Doesn’t start patrolling. I’ve debugged and it registers me as seen all the time, and the chase music keeps playing. :frowning:

It opens ONE locker, and then just stands there. I haven’t worked with the AIPerception system that much before, so all sorts of guidance is welcome.

The second to next picture is of the settings for sight perception. The last one is for collisions for lockers if that helps. :slight_smile:

[grid]






Any and all help is appreciated!

Hey, Goshi,

This is A LOT.

You should keep questions simple because very rarely will people rewrite code for you. It certainly does happen, but usually it’s when the person has little to no code to begin with.

Start with this:

I’ve personally had issues with GET_RANDOM_REACHABLE_POINT_IN_RADIUS and GET_RANDOM_LOCATION_IN_NAVICABLE_RADIUS. I find that one or the other works, depending on the situation.

I would attempt converting all of your vector patrol nodes to one or the other, testing them both to see which is more responsive.

Hello! Thank you! All the problems were kind of connected so I wrote everything, maybe I should try again.

The most important thing to tackle, is the problem with the lockers.

I’ll try to convert the nodes!

So I end up getting an infinite loop detected for the patrol, if i use it on event begin play (tried to test this isolated).

Photo please?

If all you did was swap out the nodes, and you got an infinite loop, that may explain the previous erratic behavior.

I’ve changed things quite a bit. So idk how helpful it’ll be. Right now, I’m mostly concerned with trying to solve the problem of the AI’s behavior with the lockers.

I decided to put things back to the way they were with patrol. But honestly the enemy just stands there.

I have no idea where you are with you coding of this function.

I think you should trash it and start over. It’ll probably be faster that way.

Take your time, and make sure each step works.

This is where I am right now. :heart_hands: The root of my problems is the aiperception system.
The patrolling behavior is not as important anymore tbh.

I didn’t read through your code, so, although you’re intimately familiar with it and what you’re trying to do, I am not.

That said,

What EXACTLY is your issue with the Perception System?

You said:

As in, the AI doesn’t behave properly after SENSING AND LOSING the player. Now you’re saying it doesn’t perceive at all?

This is what I mean about keeping it simple, because you have to be VERY specific or important details get confused.

Sorry for late answer. I managed to detect whether or not the AI can see the player visually.
Right now, this is what’s going on:

This is as far as I get when it comes to being able to detect when the AI is, or isn’t seeing the player. I can’t do anything more with that.

The next step is to essentially figure out how make the codes for having the enemy go to the nearest locker after not seeing me anymore, and then a random locker, functional. This is where I’m completely stuck

OOOKKKKAY.

Much easier. I appreciate it.

Gimme a sec to look this over…

Just to be clear, the enemy CAN SENSE the player? You have no issue with that?

Yes! Sorry for the weird phrasings. It’s almost 4 am :nail_care:t4:

Got it.

Wait, don’t answer yet, because I realize that you may only be allowed to post a certain amount per day.

The issue I see is with the FOR LOOP:

The FOR LOOP cycles through an array in ORDER. That’s why your enemy goes to the same locker. Whichever locker is first in the array is always going to be selected. You need to randomize this property.

Gimme a sec…

If the distance is too far, you can loop the function in on itself to try again. I’m just showing the first part of what you could do. You would get rid of the FOR LOOP.

This is essential what the macro looks like. However, instead of search locker, I have another output “fail”.

From success out of it, I drag it into the catch player node
And the fail one goes into go to random locker.

In case you needed more information.

This hole gets deeper and deeper.

Dude, I really think you should start over, because if you placed something in the wrong place or used the wrong node, it can take forever to figure out what’s going on.

Again, step by step. Make sure that you can do all of these things SEPARATELY and then if you know for sure it is possible, combine them.

Honestly it’ll take me more time to do this all over again ATP. Good news, SOME of it is working(?)

So, the ai now stops by the lockers. It just stands there.I think the trouble may lie in those BP’s now.

You’re going to have to “scrub” (look through it very carefully) your code.

I know you think it’ll take longer to start over, but I really disagree.

It’s been 2 days and you still haven’t figured out the issue.

I think you’re mixing up the perceived effort of starting over with the actual time it’ll take to redo the code. The effort, not the time, is what irks you.

I’m talking from experience, but it’s up to you. Just keep in mind that if you code on a shaky foundation, you’ll have more issues down the road. Your stuff needs to be AIR-TIGHT.

Good luck.

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.