Add AI Perception Component Node

I have an AI character and initially I had added the AI Perception component on the character. But that didn’t work in the built version of the game. So I have the “Add AI Perception Component” node on Event Begin Play. And that actually works when I build the game. Although I have run into another problem. I noticed that the “detection by affiliation” option in the BP node is empty. And my AI character cannot sense the player character.

How do I go about adding the detection by affiliation options in the Blueprint Node?

I don’t have a problem with the perception component. When you say “built”, do you mean packaged in “shipping” mode? How does it not work?

Sorry, yeah I mean packaging the game. I tried both shipping and development. I noticed in shipping the AI character never responded to the Player. So I packaged in development mode, turned on the AI debug and I can see that the sight and sound configs reset to it’s default settings. It works fine in PIE

Hmm… It actually gets larger in the packaged version. I’ve seen Mieszko say that the affiliation feature was not working properly but that was a while ago. I avoid that feature at the moment. I turn on all affiliations and filter out friendlies when the perception event fires (using my own affiliation enum).

One other thought: is the perception component in the AI controller? I’ve heard that putting it in the character can be problematic.

It’s actually not getting larger in the package version… it’s just resetting to default. So this is what I figured out so far:

When packaged, the AI Perception Comp resets all it’s sense configs to default. Which in turn resets the affiliation to just “Detect Enemies” hence making the player undetectable. I have no idea why it’s resetting though.
So I tried adding the AI Perception Comp in runtime using the “Add AI Perception Component” blueprint node… set the sense configs as I want. Now when I package that version, It actually retains the correct sense configs. But the issue I have with the 2nd method is, I cannot set the affiliations in the blueprint node. Looks like those options are just not available.

And yes, it’s in the AIController. I even tried it on my AICharacter and everything works fine while testing in the editor. It’s just all broken when packaged

228401-capture.jpg

I can confirm that the affiliation settings are missing. This should be submitted as a bug. Don’t count on it getting fixed though.

VENT

In many ways, the AI system is far from acceptable IMO. And it’s been languishing for years. Lots of issues and unfinished features, complicated customization, and an almost complete lack of support make for a difficult development effort. And if it was actually functioning perfectly, the entire system would be antiquated at best. I mean, they’re serializing variables just to pass them between modules.

I have an open question but it seems like only the most basic questions get support from Epic staff – who are pretty much the only ones who know more than me about it.

END-VENT

As far as the component resetting, I don’t know. I have no issues with that so perhaps it’s something you’re doing somewhere else?

Did you try what I was saying? Turn on all affiliations and filter out friendlies in the blueprint?

And I’m confused by you saying that the packaged game doesn’t have a larger detection radius. It looks obviously larger to me.

Yeah I think it is a bug on the BP node. I’m still blank on why the normal method just keeps resetting. Maybe there is someway I have to “initialise” it or something.

I’ve seen MieszkoZ respond on here and from what I saw, it was more like “don’t count on it, deal with it”. I’m new to AI in general, and previously used the PawnSensing component. Maybe I should just try building an AI using that system.

Btw, are you doing all the AI Perception in C++? I’ve set up my whole system in blueprints only. Maybe that might be a catch?

Ah it looks bigger because it’s defaulting to it’s radius of 3000 and view angle of 90 (and default affiliations). The settings I have set in the editor are like around 1200 and angle of 60. I have all affiliations set to true… and It works perfectly fine playing in editor.

btw i did submit the BP node bug too

Found this (4.16.2) AIPerception Add Problem - C++ - Epic Developer Community Forums

I guess they have him working on everything except the functionality we get. He’s a cool guy and obviously capable. Why this system is such a mess, I don’t know. I suspect it’s Epic deciding what is more profitable. And based on current trends, I suspect developers like us will become even less significant in their decisions.

It would be nice, though if Mieszko could answer more advanced questions seeing as he’s the only one who knows what the heck it’s doing in there. I was trying to expand the EQS system so I could get an actor and a vector for each test point. I got pretty far in the customization but I got stuck because there’s this serialization weirdness going on. Seems pointless and cumbersome to me but it’s definitely not clear how to customize it. That’s normally where docs and support would come in.

Can you run the packaged game in the debugger and figure out where it’s going wrong? If you build for DebugGame, you can attach VS to the process and see.

All my perception stuff is in blueprints. EQS is where I need C++.

Hey, I tested my project for your issue. I don’t see it. In my packaged build, my ranges are right and the enemies react to me.

If you can’t figure it out, I’d be happy to take a look at your project if you’re comfortable sharing it. If so, go to the forum and DM me with a link. I have the same username on the forum. Or maybe you can reproduce it in a sample project and share it here.

Yeah cool I’ll send you a zip of the project later tonight. I did try and simply add an AI Perception comp on the UE4 mannequin in the 4.19 preview and it pretty much did the same thing. I’ll let you have a look at my project and see if you can make any sense out of it. Thanks!

Ah right… EQS is still experimental isn’t it?

I sent a DM over the forums with a link to the zipped project.

Yeah EQS seems kind of new and still WIP. I haven’t touched EQS yet, I just have a predefined waypoint system for each AI character. Works for the kind of game i’m working on for now

Turns out it was nativization causing the issue. Turning that off allowed the AIPerception component to work properly. This could possibly be a bug.