A warning on Isograms

After using RandRange, I noticed I was getting good compiles, but Unreal would crash instantly.
I realized what I’d done after a few hours of troubleshooting. I had a statement in the wrong sequence from the lecture.

I was calling:

   SetupGame();
    Isograms = GetValidWords(Words);

Then, in SetupGame, I was calling:

void UBullCowCartridge::SetupGame()
{
    
    HiddenWord = Isograms[FMath::RandRange(0, Isograms.Num()-1)];

So I had Isograms being defined after it’s first use in SetupGame. Doh! No wonder those two calls were the run time crash. I just didn’t see any syntax issues, and couldn’t figure out the bounds issue. It was calling the zero index, without ever having anything populated in Isograms. Lesson learned.

1 Like

Privacy & Terms