Hi there! I wanna write component that will alredy loads mesh on instantination onto level.
I’m already tried this way load, but no success.
#include "UObject/ConstructorHelpers.h"
#include "Components/StaticMeshComponent.h"
// Sets default values
AMyPawn::AMyPawn()
{
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
mesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("Mesh"));
mesh->SetupAttachment(RootComponent);
static ConstructorHelpers::FObjectFinder<UStaticMesh> CubeVisualAsset(TEXT("/Game/Content/Mesh/Box1.Box1"));
if (CubeVisualAsset.Succeeded())
{
mesh->SetStaticMesh(CubeVisualAsset.Object);
mesh->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
mesh->SetWorldScale3D(FVector(1.f));
}
}
When I drag this c++ class on to level new APawn do not have any boxes mesh. it’s just empty(