Can AI not see player pawn if not in Persistent level?

Howdy! I have ran into a problem! I recently moved my player pawn to a sub-level and all AI broke…
Can AI not see player pawn if not in Persistent level? does the player pawn need to be in Persistent level?
My Setup:
-Persistent level(main)
–Sublevel A (has AI enemies)
–Sublevel B (has player pawn that I possess at begin play)

The problem is my AI has stopped working… I did a few tests and it seems If I stream in “Sublevel A” and if player pawn is in the “Persistent level” nav and AI works. But when I try to have the player pawn in a sub level the AI does not nav to my player pawn. any ideas? am I missing something? can I force the AI to see the player with “Register Perception Stimuli Source”?

anyways any help would be awesome!

so after more tests I found that it might not be because of the level the pawn is in… it seems to be something with possessing a new pawn. I have Pawn-A and Pawn-B (both are the same Blueprint). Pawn-A is used for the intro of my game, after completing the intro I possess Pawn-B and destroy Pawn-A, This seems to break the AI. BUT when I start the game with Pawn-B, complete the intro with Pawn-B, all the AI works. How can I change player pawns without breaking AI? my mind is so confused lol! is there any clean up I need to do? Is it because Pawn-A and Pawn-B are the same BP and just instances of each other? should I make separate “intro pawn” ?

it seems like I should b able to switch pawns and keep AI working …

Thanks in advance!

Can you define “not working” please? Based on your original post, I assume your agent didn’t move to the Player? How do you set the Target for your agent? Are you using BehaviorTrees?

Hey @Kontur Thanks for the reply!
By not working I mean the NPC or agent does not move to player or “see” the player if I possess another pawn. (whats strange is the pawns I am switching between are the same Blueprint Class and have same Actor Tag) yes I am using BehaviorTrees and my AI comes from the “AI Behavior Toolkit” on the market place. ( AI Behavior Toolkit in Blueprints - UE Marketplace ) its seems to find targets via Actor Tags. Its very strange, when I possess another pawn they cant “see” the new pawn. but they will still attack the old vacant pawn. also if I place other “friendly” NPC Pawns (with the proper Actor Tags) the Enemies attack the NPC’s no problem they just cant seem to see me when I switch pawns. please let me know if you need any more screenshots/ or more info as I am a n00b with AI…
Thank you again for your help!!! :smiley:
90a52e1ee423ec8afc4a0eab569c6942d4bb4277.jpeg
6f2b4eed7545d7efa774cbb5ba693cc504e3f853.jpeg
42a66b2221da08838630c7231a4a0c6f0f466cfa.jpeg213d5f658acc7bdb8872d6d3b96bf2746c3f15ca.jpeg


I Fixed it!!! after fiddling around some more I found that adding these two components to the player character fixed the problem!!
5914a486831082d770be98f23f79b5dcde8aed57.jpeg

Didn’t work with me! for me, the issue is with the Navmesh component, when running each level separately things work fine but when using a streaming level the AI freezes in its place

Sorry to bump this thread but I’m facing the same issue when trying to integrate the AI Behavior toolkit with a custom project from the market place called FPS starter kit.
The AI in the behavior toolkit doesn’t seem to detect the player pawn from the FPS Kit unless it’s the default BP_Player from the AI behavior toolkit.
Any help would be appreciated!

Engine Version: 4.27

I just ran into this issue.
I don’t know how your AI Pawns are placed in the level, but in my case I have mine placed in the streaming level, and when I load the streaming level they are “spawned”, but not in a dynamic way.
Debugging the code, it looks like there is an event called FOnActorSpawned that the AI System is using to communicate to the PerceptionSystem to register sources. Unfortunately the OnActorSpawned delegate event is only called when an Actor is spawned dynamically. (As far as I can see, by debugging. I’m only seeing my Controllers getting called in this callback, they are both spawned dynamically from the Pawn)
I solved the issue (In a code way) by making a game specific AIPerceptionSystem and then re-running bits of logic to register all pawns as source whenever my streaming is completed.
The other way to solve this is to spawn your AI Pawns dynamically (Which I think I’ll ultimately end up doing, but I wanted to understand this problem first. I just haven’t gotten to my AI Spawn systems yet)
Another way to solve that is more BP friendly is to get all of the Actor classes of Pawn AFTER your level has streamed in and to call RegisterPerceptionStimuliSource (it’s a BP Callable function) on each Pawn.

TLDR Problem:

  • Hand placed Pawns won’t get the events necessary to Register themselves as source when streaming them in

TLDR Potential Solutions:
1.) Make a game specific AI Perception System in C++ and re-run bits of logic from UAIPerceptionSystem::StartPlay when you’re done streaming in your level
OR
2.) Spawn AI Pawns dynamically
OR
3.) Once level streaming is finished GetAll Actors of Pawn, loop through them and call RegisterPerceptionStimuliSource on each of them

Let me know if anyone has any specific questions.