Hello everyone, I am working with Raw Object (Object Assets? Basically, they inherit from “object”) and Damage Types, and the assets don’t seem to be loaded when I open the engine. If I open the engine and immediately try to run the game, those assets return a Null reference. To make them work I have to open each asset of those types for editing, then they work normally. They are also loaded when chosen as default value in a variable, but not as you open the engine, you do have to select them afterwards.
I’ve been looking on this forum and other websites for an answer or at least and open bug report, but couldn’t found any. I thought that Raw Object were causing issues for some obscure reasons, but the fact that this also happens with Damage Types, which are technically a default Class, makes me wonder if something is wrong with the engine, not my project. Any pointer is appreciated
I am working with Raw Object (Object Assets? Basically, they inherit from “object”)
I don’t know if there’s a terminology for them, but “BP assets with UObject as parent class” would be descriptive if I’m understanding you correctly.
the assets don’t seem to be loaded when I open the engine.
No assets get loaded on their own unless something specifically loads them.
If I open the engine and immediately try to run the game, those assets return a Null reference
How are you referencing and loading in the assets? Assets are only loaded when you tell them to load. Or, when something that hard references them is loaded. They won’t just load on their own. Maybe that’s the issue you’re having?
but not as you open the engine
Do you mean as you open the Editor? The “Engine” starts both in packaged games and also in the Editor.
Thanks for your reply and the clarifications, they are insightful.
How are you referencing and loading in the assets?
The assets are referenced in an Actor Component (actually, a child of a Skeletal Actor Component) Blueprint. This is an Object that I spawn in the game and attach to different Character, similarly to the gun in the First Person Example, but some of the variables in the components are changed by those BP Assets inheriting from UObject. I am using soft references to store which BP Asset use to pick the variables, so maybe that is the problem?
Do you mean as you open the Editor? The “Engine” starts both in packaged games and also in the Editor.
I mean open the Engine, as this problem is present both in Editor and in packaged builds.
I am attaching a screenshot of the BP, hopefully it explains a little bit better the situation.
The “Rarity Algorithm” variable is the BPAsset inheriting from UObject (BP_RarityAlgorithm from now) “Pick Parts” is the function that returns the Null reference error. Again, this happens only if I don’t open each child of BP_RarityAlgorithm before playing. Once I open them once, everything works properly.
Yes I see the problem now. Rarity Algorithm is a Soft Class Reference (bright pink color) which you’re then converting to a hard Class Reference (that little converter node that turns the pink line into a purple line).
Soft Class References are powerful as they are never loaded for you and as such don’t count as a dependency, but you do have to manually load them yourself with the AsyncLoadClassAsset function at some point.
That converter node (called Get() in this case) never loads anything, how it’s described is that it returns the object if it is already loaded, or null otherwise.
Your class isn’t already loaded, in your case unless you hack it by opening up the asset manually in the editor first. But that’s just that, a hack.
So you have two options to fix this. Either convert the variable’s type into being a normal non-soft Class Reference, or keep it as a soft reference but call AsyncLoadClassAsset before loading it. Be adviced that the AsyncLoadClassAsset function can take a little while before the asset gets loaded, you’ll have to take that into account in your gameplay. Here’s an image of how you would use either type: