Hey Guys I managed to get some things in my first C++ code to work, feels like magic.
Right now the code creates a cube but I want i to make many many cubes think of it like minecraft.
It basically needs what blueprints have in the “for loop” function.
How do I achieve this?
My CubePlacer.cpp
#include "test.h"
#include "CubePlacer.h"
// Sets default values
ACubePlacer::ACubePlacer()
{
Grabber = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("letmetakeaselfie"));
static ConstructorHelpers::FObjectFinder<UStaticMesh> StaticMeshOb_torus(TEXT("StaticMesh'/Game/Geometry/Meshes/1M_Cube.1M_Cube'"));
if (StaticMeshOb_torus.Object)
Grabber->SetStaticMesh(StaticMeshOb_torus.Object);
}
// Called when the game starts or when spawned
void ACubePlacer::BeginPlay()
{
Super::BeginPlay();
}
My CubePlacer.h
#pragma once
#include "GameFramework/Actor.h"
#include "CubePlacer.generated.h"
UCLASS()
class TEST_API ACubePlacer : public AActor
{
GENERATED_BODY()
public:
// Sets default values for this actor's properties
ACubePlacer();
// Called when the game starts or when spawned
virtual void BeginPlay() override;
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Base)
class UStaticMeshComponent* Grabber;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = CubeSize)
class UStaticMesh* DesiredMesh;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = CubeSize)
int32 xCells;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = CubeSize)
int32 yCells;
UPROPERTY(VisibleAnywhere, BlueprintReadWrite, Category = CubeSize)
int32 zCells;
};
Many many thanks!