Spawning of an Actor with a WidgetComponent in C++

Hello,

I have an Actor that contains a WidgetComponent that contains a UserWidget. If I spawn in C++ at runtime my Actor’s class, the WidgetComponent is invisible and the UserWidget is NULL. If I create a blueprint class from my Actor’s class and spawn it, everything is OK. Is it an expected behavior of Unreal Engine? If not, I’ll send the code to show. Thank you for your answers.

Best regards,
Alexander Temnyakov

You should always start by posting the code, it makes life easier for the person answering the question. It’s very possible to have a WidgetComponent or really any kind of object created at the C++ level when the Actor is created.