How to add static mesh component in C++?

I’m trying to find the C++ equivalent of the “Add Static Mesh Component” blueprint node.
So far I have followed this solution (Add Static Mesh Component C++ - C++ - Unreal Engine Forums) as showed in the attached image, but the error i’m receiving is

UStaticMeshComponent MyMeshComponent

  • Pointer to incomplete class type is not allowed

2 Likes

in the cpp header:

#include "Components/StaticMeshComponent.h"

all classes which you want to add needs to be included.

UStaticMeshComponent - in your case its incomplete class, if you mouse click on it and then press F12 you can find full path to this class.

1 Like

thanks, it worked