How to load a static mesh ? c++

Hi everyone !!
I’m working on a project which create mesh procedurally.
I’m creating it using DoConvertActors and can’t figure out how to load it after in order tp modify it.

This is not working

AActor *Mesh = Cast(StaticLoadObject(AActor::StaticClass(), nullptr,TEXT( “/Game/MeshName”)))

I’ll be happy to read any kind of help
Thank you

A static mesh is not an AActor, it’s a UObject, casting it to AActor will always give you a null pointer.

Also, when you Cast, you need to include the class you’re casting to as a template argument.

Try this:

UStaticMesh* Mesh = Cast<UStaticMesh>(StaticLoadObject(UStaticMesh::StaticClass(), nullptr, TEXT("/Game/MeshName")));

or:

UStaticMesh* Mesh = LoadObject<UStaticMesh>(nullptr, TEXT("/Game/MeshName"));
1 Like