Hi @Alexa.Ki !
There are a few things that are weird in the code you sent, I’m not sure you are using the Ampersand & correctly, what it does is use the value of the reference and if it is edited, it edits the reference. And it is usually used for functions that return or change more than one value.
What I would try is to remove all ampersands from the GetRandomLocation, so it ends up something like this:
FTransform AMyGameMode::GetRandomLocation(const TArray<FTransform> Locations)
{
return Location[FMath::RandRange(0, Location.Num() - 1)];
}
I added a const too, which means that the variable Locations won’t be modified on the function, as it is only getting one random value from that array, it is correct that it won’t alter the array of locations.
Then I would change these
To this:
FTransform Location = GetRandomLocation(Available);
UniqueArr.AddUnique(Location);
For Tarrays, you can also call the .Add(), so it ends up as UniqueArr.Add(Location)
As for this
The error doesn’t match with what you uploaded, so maybe it’s somewhere else.