This issue has been driving me insane and is basically a fatal error that is preventing me from making any progress on this project because anything i make will ultimately be immediately lost.
I have a custom component that derives from the AI_Perception component. Everything about it works, the functions work fine, it shows up in my components list, etc. Except whenever i open my project again any references to it in blueprints, any actors that had it added as a component, all of it disappears.
the c++ class belongs to my plugin module, but i have confirmed this data loss happens whether its referenced in the plugin content blueprints (example 1) or project blueprints (example 2).
Quite frankly, whatever this is is making c++ completely unusable for me. I’ve tried updating to the latest Visual Studio, turning off and on live coding, etc. None of it seems to work. Please tell me how to fix this.
If that doesn’t help, could you scour the output/message logs for any warnings/errors that get outputted after you start up the editor and open one of the blueprints with errors, and paste them here?
That did it, i think. Just tried setting it to “PreDefault” right before i saw this reply xD seems to have fixed the issue. Thanks! Hopefully this post can remain for anyone else who is having this issue.
I’d suggest you edit this topic to a “question” and then mark whichever answer as the solution to make it easier to discern what the answer was if someone is having the same issue.
Actually this fix only created a new issue tbh. Loading an actor component that inherits from AIPerception in the PreDefault phase breaks it; it registers too early before MyOwnerWorld exists and fails silently, none of the event bindings exist, it can never tick, and CurrentlyPercievedActors never updates.
I have no idea how to fix this. I need it to be loaded in the default phase but before my blueprints load. Or somehow between pre-default and default. I am stumped.
Could you please provide screenshots for the code/BP in question? Perhaps your initialization depends on things it’s not supposed to and/or is too early (like in OnConstruction), but we have no way of knowing unless we see the logic.
I’ve actually been grappling with this long enough that i’ve tried it 2 separate ways, one with the logic inside a component that inherits from AIPerception and another one with a dummy actor that loads the default AIPerception and modifies it from outside. Neither one is working.
I’ve seen your other thread as well (with the ensure stack), and neither of these snippets seem to correspond to that ensure stack, is there a third version? I don’t see how the provided snippets register the component too early, there is no manual RegisterComponent call.
AddOwnedComponent in APerceptor::APerceptor seems unnecessary, but it shouldn’t be causing any issues on its own.
UActorComponent has bAutoActivate, way easier than manual Activate() in UDynamicPerceptionComponent::BeginPlay.
Yeah thats what i’m confused about too. I think the ensure stack is from the most recent version with the Perceptor actor? But that part seems to happen no matter what. With the component version it also has another error stack complaining about trying to register a component that was already registered so thats how i came to that conclusion.
But yeah i’ve tried many variations on this, including some with the constructor completely empty any configuration moved to BeginPlay, it still seems to be an issue. It seems to be related to the loading phase, somehow it tries to register itself during the pre-default phase no matter what i do. All the other functions on the c++ class just have to do with getting and modifying the values on that AISenseSight config. Its nothing crazy, but i have no idea how to make it load specifically when it needs to–before my blueprints load, but after MyOwnerWorld is created (which seems to be after the PreDefault phase?).
Do you have a discord? I’m happy to show you more on stream if you’re willing.
Can’t hop on discord atm, but either way I’d prefer to either debug it myself locally and/or log what happened here for future reference.
If you zip and attach your Source+Content+uproject (should be small in total), or make an example project with just the malfunctioning part, I can try it out myself later (and so can anyone browsing the thread).
Alternatively, or in the meantime, you should be able to catch that ensure with your debugger and see the stack that’s causing the early registration and either figure out what went wrong or copy the puzzle pieces here, I’m really curious as to what’s causing the RegisterComponent during plugin loading.
Depending on your IDE, you should be able to start the debugger along with the game and when the ensure pops it should automatically pause execution and show you what happened. In Visual Studio starting the project through this button should do the trick:
Ok i tried it until the breakpoint and it literally just gives me this:
Ensure condition failed: MyOwnerWorld [File:D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\Components\ActorComponent.cpp] [Line: 1528]
[2025.06.08-13.38.39:973][ 0]LogOutputDevice: Error: Ensure condition failed: MyOwnerWorld [File:D:\build++UE5\Sync\Engine\Source\Runtime\Engine\Private\Components\ActorComponent.cpp] [Line: 1528]
This is on startup though. The editor hasn’t even opened and begin play hasn’t even happened.
Yes, and now go through the call stack in the debugger and find what’s calling that function to figure out what’s wrong, or screenshot the previous few call sites if you don’t see anything obviously wrong in the stack.
Oh wait nevermind… now its not triggering that ensure stack? But the perception events are still not firing for some reason and the component isn’t ticking… Its still broken now but its just not throwing any errors. wtf.