How do I create a widget and add it to the viewport in c++?

How can I essentially do “create widget”->”add to viewport” inside of a c++ implementation file? I can’t find ANYTHING to explain how to do this, but I was told that it was possible.

Additionally, how can I play an animation in c++?

I want to create an error message that fades in and out and I’ve already created the widget and the animation for it. I just need to do it at the fight point in a cpp file.

Thanks in advance!

this video should help. its what I followed when I had the same issue, hope this helps!

Wow, that’s exactly what I was looking for. Thank you so much!

i think this video will be helpfull. How to Spawn/Create Widget in Unreal Engine C++ - YouTube

the answer without having to watch videos

this post also contains lots of useful info (a bit old but still useful)

the answer without having to watch videos

The real hero, right here.