FObjectInitializer::CreateDefaultSubobject changing object type results in invalid objects
I have a native abstract uclass called Grenade with an UCapsuleComponent defined as a UPROPERTY.
Inside the constructor I initialized it like this:
It works just fine. I'm able to throw the grenade and detonate it inside the game. Due to a few issues with UCapsuleComponent we decided to replace it with an USphereComponent. Unfortunately, the game crash upon changing the object type to USphereComponent.
And inside the constructor:
The details panel inside the blueprint class won't show anything which in my estimation indicates it has not been initialized:
If I add this to OnConstruction in addition to the code in constructor of the class it works inside the game (though still the details panel is empty):
I suppose the blueprint class caches the constructor somewhere, so I created another blueprint. The first time I open the blueprint the Details panel shows the properties for the collision component. If I run the game and crash it it won't show anything any more. I tested this on both Linux/Clang and Windows/VC++. I even tried renaming Collision to Collision2 or removing the original blueprints class from the project. None of that works.
asked Dec 17 '17 at 08:54 AM in C++ Programming
yes unreal buildsystem don know how to clean up hios own .... deleting all folder, apart from content,config,source might help aswell.
answered Dec 17 '17 at 09:56 AM
I've had a problem like this because of blueprint parenting. There may be a better way, but I got around this by creating a duplicate of my base class and reparenting the blueprint to that. The editor will warn that there may be problems with the reparenting but it's fine to do it since the duplicate base class is identical. Then I changed the component type in my original class and reparented back to it and it worked.
After that, there might be functionality in your blueprint that needs replacing. For example, a sphere doesn't have a half-height.
If that doesn't work, you can also try rebuilding it all from a clean project (from scratch -- as in no saved/intermediate/etc directories). You can either delete directories yourself (if you know what you're doing), or package the project to a zip and extract it into a new directory. GL.
answered Dec 17 '17 at 09:07 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here