How can I check if player is being seen by AIPerception sight?

That’s great! You should be able to tackle the door thing later. That’s actually why a lot of doors in video games swing both directions! :slight_smile:

Okay, so now the lockers. What the first Error says is "There is nothing set as TargetLocker, so we can’t tell the AI to move to it. If you click on those underlined parts, it will show you that node.

So, first, you need to use an “IsValid?” macro check on the locker (that’s the gray node) so it doesn’t try to navigate to one if one isn’t set yet.

Get us some good pictures of your code and let’s work on the locker! :slight_smile:

1 Like

Something like this?

This is of course inside the Macro “Go To Locker” Itself

Or did you mean before the function to call the macro like here?

Sorry, you’re going to have to give the whole code. I can’t see where you’re putting this function.

But what you do is you use an IsValid Check to check if the specific locker you’re about to tell it to go to is valid. you plug that in to the “InputObject.”

Basically what you’re doing here is checking if it has a place to go, before telling it to go there. You pass in the locker through the check, then if it IS valid, go to the locker, if it IS NOT valid, don’t go to the locker.




Here you go!

This is the change you suggested, if I understand correctly?

Actually, yeah! I THINK you should be good, but I don’t know what all of these things are in your game.

What happens when you test it? Let us know!


This happened!! :smiley:

So I’m NOT getting those erros (so far that I’ve checked.)
But the AI didn’t go to the nearest locker? It went straight for me.

Also, it opened a locker while on the other side of the door because it couldn’t get in.

Aw, man, that’s looking great!

I think it’s because your closest locker distance is only 10 meters. Unreal units are measured in cm.

So, pump it up to 100.000 when you reset it! That way the new one will for sure be less (unless your levels are above 1km wide).

image

1 Like

Thank you so much! :smiley:

I did that, and everything seems to be working. Except the fact that my code for the AI opening the door isn’t working. He’s just standing there. :upside_down_face:

Sorry to bother you further. But do you see what the problem could be here?


I don’t get it. The enemy should stop at the door, open it and run through.

Well the first thing I can tell you is this cast does nothing:


A cast tells the input to behave as a child of the input blueprint. It doesn’t check anything.

You need to use the “Get Class → == BP_EnemyAI → Branch” like we used earlier, and if True, THEN check if the door is open. :slight_smile:

Okey! I Will try this. But first I want to change the way the door opens and closes. It doesn’t open both ways, which would be far more convenient considering the player/AI’s position, so you don’t run into the door while it’s opening.

This is where I’m at right now. In terms of the code:

And this is what happens.

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