I was following a tutorial on how to assign a mesh to a staticMesh and I get the following error:
Exception thrown at 0x00007FFD8F47DD5A (UE4Editor-Engine.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000098.
static ConstructorHelpers::FObjectFinder<UStaticMesh> CubeAsset(TEXT("/SideScrollerTest/Content/Geometry/Meshes/1M_Cube"));
Whole cpp script:
// Fill out your copyright notice in the Description page of Project Settings.
#include "MyActor.h"
// Sets default values
AMyActor::AMyActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
UStaticMeshComponent* Cube = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("3D Design"));
staticMesh->SetupAttachment(RootComponent);
static ConstructorHelpers::FObjectFinder<UStaticMesh> CubeAsset(TEXT("/SideScrollerTest/Content/Geometry/Meshes/1M_Cube"));
if (CubeAsset.Succeeded()){
staticMesh->SetStaticMesh(CubeAsset.Object);
staticMesh->SetRelativeLocation(FVector(0.0f, 0.0f, 0.0f));
staticMesh->SetWorldScale3D(FVector(1.1f));
}
}
// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
Super::BeginPlay();
UE_LOG(LogTemp, Warning, TEXT("Hello World!"));
}
// Called every frame
void AMyActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
P.s I have no idea where to put this, the topics are so vague(Their descriptions are one sentence long, the hell?) that I decided since it’s realtime in the editor that I should put it under editor scripting.