Hi I’m trying to return in order the next index from the: private static string[ ] wordListGrandparent. I’m using brackeys tutorial on making a typing game and getting random indexes work fine, but i’m having trouble returning them in order in the public static string GetGrandparentWord() function.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WordGenerator : MonoBehaviour
{
private static string[] wordList = { "box", "fax", "cat", "dog", "gut", "put", "sub", "sin",
"max", "sax", "mop", "pet", "able", "make", "ache", "bake", "acid",
"weed", "acre", "mom", "sidewalk", "robin", "three", "four", "protect", "periodic", "somber",
"majestic", "jump", "pretty", " wound", "jazzy", "memory", "join", "crack", "grade", "archie",
"kimo", "boot", "cloudy", "sick", "mug", "hot", "tart", "dangerous", "rustic", "economic",
"weird", "cut", "parallel", "wood", "interrupt",
"guide", "long", "chief", "mom", "signal", "rely", "abortive",
"hair", "earth", "grate", "proud", "feel",
"hilarious", "addition", "silent", "play", "floor", "numerous",
"friend", "pizzas", "building", "organic", "past", "mute", "unusual",
"mellow", "analyse", "crate", "homely", "protest",
"society", "head", "female", "eager", "heap", "dramatic", "present",
"sin", "box", "pies", "awesome", "root", "available", "sleet", "wax",
"boring", "smash", "anger", "tasty", "spare", "tray", "daffy", "scarce",
"account", "spot", "thought", "distinct", "nimble", "practise", "cream",
"ablaze", "thoughtless", "love", "verdict", "giant", };
private static string[] wordListGrandparent = { "dom", "plus", "abby", "equals", "you", "are", "going", "to", "be", "a", "grandparent", };
public static string GetRandomWord()
{
int randomIndex = Random.Range(0, wordList.Length);
string randomWord = wordList[randomIndex];
return randomWord;
}
public static string GetGrandparentWord()
{
int nextIndex = 0;
string nextWord = wordListGrandparent[nextIndex];
return nextWord;
}
}