Beginner question on Actors & Bringing Them into World

Hi guys I’m a beginner to the engine and I have a couple of questions. I’m trying to just put a model in my world and see if I can attach a class to it. For example, I have a .fbx crappy model I found for free on the internet. I know that Pawns are the base class to represent characters in your world. So I created a subclass of Pawn, let’s call it MyPawn. So I have my .fbx model and I want to attach MyPawn to it. How do I do that. Do I have the unreal concepts wrong? When I bring the model into my world it comes up as a skeletalmeshactor. Do I have to subclass skeletalmeshactor instead? Again just a beginner trying to play around so any answer would be helpful.


It’s other way around, you attach meshs (and not only, stuff like sounds or lights too) in form of components to a any actor based class, and each of actor can have many of them attached to itself. And StaticMeshActor is just a simple actor to place “dead” meshes to level

First you declere subobject pointer in to header file on which you will set up a component

class ASomeActor : public AActor

	TSubobjectPtr<UStaticMeshComponent> MeshComp;

Then in your actor/pawn class constructor:

ASomeActor::ASomeActor(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
        //Grab static mesh from assets that you previously imported (AND SAVED!) using Content Browser, in argument you place path to mesh
        //You can get it by right clicking the mech in content browser and then "Copy Reference"
	static ConstructorHelpers::FObjectFinder<UStaticMesh> Mesh(TEXT("StaticMesh'/Game/SomeAssets/SomeMesh.SomeMesh'"));
        //Create StaticMeshComponent
	MeshComp = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("Mesh"));

        //Set your mesh you just grabed to the newly made component
	MeshComp->StaticMesh = Mesh.Object;

        //Set this component as a root component for this actor
	RootComponent = MeshComp;

You could do also other way (and a lot more efficient), editor has component editor only for based blueprint classes, but can make Blueprint actor from class you made in C++, so insted of attaching component by code (or else you really need not) you make base class for blueprint which let you use component editor. I really recommend to play around with blueprint first before you start playing with C++ as you seem to not understand the basics of how actor is constracted and blueprints is easy way to learn it, also read documentation:

Gere you can find other kind of components: