I have a C++ actor component that works perfectly as intended - I can instantiate it, use it in a blueprint and it does what it’s supposed to. After closing the Editor and reopening, the actor does not instantiate and instead I get a console warning:
Component class is not set for 'ActorName' - this component will not be instanced, and additional warnings or errors may occur when compiling Blueprint 'BP_FirstPersonCharacter'.
I’ve followed numerous discussions on this topic. Most people are saying turn off Live Coding and compile your code in Visual Studio with the Editor closed, and make sure you build for “DevelopmentEditor”. I already am doing this, still no luck. The problem occurs even if I create a brand new ActorComponent from the editor without any extra code.
Related:
Custom component keeps dissapearing - Development / Programming & Scripting - Epic Developer Community Forums (unrealengine.com)
So, I went to one of my other C++ components and tried creating an instance of my actor inside of it:
MyOtherComponent.h:
class UMyComponent* myComponent = nullptr;
MyOtherComponent.cpp:
myComponent = CreateDefaultSubobject<UMyComponent>(TEXT("myComponent"));
All of a sudden when I open editor, all my blueprints that use MyComponent work and the error is gone. I have no idea why.
1 Like
Hey there @MadMartigan! It’s likely related to a live coding issue, and live coding refresh that corrected it. Are there any errors that remain at runtime with the original?
There are no errors, but I don’t think the problem is related to live coding. I can toggle the issue on/off by simply commenting/uncommenting this line in C++:
myComponent = CreateDefaultSubobject<UMyComponent>(TEXT("myComponent"));
Note that the component was already instantiated as part of a blueprint so it’s unclear why I would need to also create it as a subobject of a component in the blueprint in C++. At least I have a workaround now, but this is odd.
2 Likes