After trying multiple different things I am not sure how to proceed.
When I have the log within the for loop it crashes.
This happens when the count is declared in the loop and outside the loop.
And when the UE_LOG is inside the loop referencing nothing and just printing plain text.
when the Log is outside the loop it works just fine.
Everything else is working as expected.
If this is something really obvious I’m sorry, this is my first week and a half with unreal and c++.
// Fill out your copyright notice in the Description page of Project Settings.
#include "Spawner.h"
#include "Engine/World.h"
#include "TestObject.h"
// Sets default values
ASpawner::ASpawner()
{
// 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;
SLoc = CreateDefaultSubobject<UArrowComponent>(TEXT("Start Location"));
RootComponent = SLoc;
}
// Called when the game starts or when spawned
void ASpawner::BeginPlay()
{
Super::BeginPlay();
MapSpawn();
}
void ASpawner::MapSpawn()
{
SVarA = 5;
GEngine->AddOnScreenDebugMessage(-1, 10, FColor::Red, TEXT("Actor Spawning - Spawner"));
int32 count = 0;
for(;count < SVarA; count++ )
{
FTransform SpawnLocation;
GetWorld()->SpawnActor<ATestObject>(ATestObject::StaticClass(), SpawnLocation);
SpawnLocation = TestObject->GetActorTransform();
// UE_LOG(LogTemp, Warning, TEXT("NUMBER: %i"), count); <== THIS OR THIS ==> UE_LOG(LogTemp, Warning, TEXT("NUMBER: ")); RESULTS IN A CRASH
}
UE_LOG(LogTemp, Warning, TEXT("NUMBER: %i"), count); // THIS IS FINE
}
// Called every frame
void ASpawner::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}