Hi!
I’m using Unreal 5.2.1. with C++ to develop a Tetris like game.
I have this method:
FVector UTBlocksSpawnerSubsystem::GetFallingLocation() const
{
FVector StartLocation;
if (UWorld* World = GetWorld())
{
TArray<AActor*> ActorsToFind;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), ATStartPointActor::StaticClass(), ActorsToFind);
if (ActorsToFind.Num() == 1)
{
const ATStartPointActor* StartPointActor = Cast<ATStartPointActor>(ActorsToFind[0]);
if (StartPointActor != nullptr)
{
StartLocation = StartPointActor->GetActorLocation();
}
}
}
return StartLocation;
}
And now here it comes my problems with C++. How can I know if I get a valid location?
Maybe I can use a FVector*
to check if it is nullptr
. Or maybe I can implement the method in another way. But I don’t know.
Thanks.