Im trying to change the context of a Text UI Element by cycling through a string index each time the player hits space, using this:
Supposedly, it should change the text two times and stop at the last one, waiting for C to change the whole scene.
Right now, it’s not even changing. It keeps rewriting the first string “text1” over and over. I can see “text2” trying to appear when I press space, but it goes right back to the first one.
Because you reset the index and declare your list each frame, your text will never be set to text2 or text3. You have to declare your index and your list as class members instead of local variables.
Moreover, read your code carefully, and you will see that you are trying to detect a keypress on C the same frame you try to detect a keypress on the spacebar, which is almost impossible.