Blank Project doesn't Load static mesh but works in Sample Projects

Hello adventures!

Today I have a little question to do about something quite similar to a recent post(this right here).

I simply have the code below and it works fine when I start a project from samples provided by the unreal engine itself, but whenever I try to start a new Blank project the code turns useless despite success on code compile, but it just doesn’t find the static mesh to load in a first looks like unreal engine totally ignores that I have assets in my folder.

In resume in a unreal engine sample(like FPS, third person, etc) project it works, but ina blank project not.

Perhaps I need to do any configuration to put this code to work? I don’t know what to do now, I should apreciate any help on this.

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/Actor.h"
#include "MyActor.generated.h"

UCLASS()
class CUBEWORLD_API AMyActor : public AActor
{
	GENERATED_BODY()
	
public:	
	// Sets default values for this actors properties
	AMyActor();

protected:
	// Called when the game starts or when spawned
	virtual void BeginPlay() override;

public:	
	// Called every frame
	virtual void Tick(float DeltaTime) override;

	UPROPERTY(EditAnywhere, Category = MyMesh)
	TObjectPtr<UStaticMeshComponent> umesh;
};

// 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 dont need it.
	PrimaryActorTick.bCanEverTick = true;

	static ConstructorHelpers::FObjectFinder<UStaticMesh> l_mesh(TEXT("/Engine/BasicShapes/Cube.Cube'"));

	umesh = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("MyUmesh"));

	SetRootComponent(umesh);

	if(l_mesh.Succeeded())
	{
		GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Green, TEXT("Ok"));

		umesh->SetStaticMesh(l_mesh.Object);

	} else {
		GEngine->AddOnScreenDebugMessage(-1, 10.f, FColor::Red, TEXT("Fail"));
	}
}

// Called when the game starts or when spawned
void AMyActor::BeginPlay()
{
	Super::BeginPlay();
	
}

// Called every frame
void AMyActor::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);

}

Ok I actually going crazing right now. I was going to search for a solution to this problem and created a new project and run the same code and for some inexplicable reason it worked even after a tried dozen of times before🤨

Unreal Engine is going to make me crazy :clown_face::rofl:

Solved.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.