Cant change state

Hi, i have an issue where the state is not changing from starting state, can you please take a look at my code please?
i can access other states “story text var”, but cant set state to the pnext one.

EDIT: i am using different input keys because of my keyboard layout

Hi,

Welcome to our community! :slight_smile:

Have you already compared your code to the Lecture Project Changes which can be found in the Resources of this lecture?

For more readability rename state to currentState, so you will understand the flow.

at start your currentState is equal to startingState.

You want to get states from an array. arrays have indexes which is numbers is square brackets. [0], [1], etc…

where is your saved index? Think of storing current array index in some integer variable.

then after pressing key to get next state add to curent index ++

should look like this
else if (input.GetKeyDown(KeyCode.S))
{
currentIndex ++;
currentState = nextStates[currentindex];
}

Thank you, i reviewed my code for 100th time and found out i might be dyslectic or something…
and also found the error. I was assigning nextStates to wrong variable “startingState” instead to “state”.
Thanks again.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms