Hello, I need some help whit Adventure Game! I have an error CS1061

Hello! I’m new here! Can someone help me! I’m stuck whit a problem!!!
error CS 1061
Assets\Scripts\AdventureGame.cs(33,48): error CS1061: ‘State’ does not contain a definition for ‘Lenght’ and no accessible extension method ‘Lenght’ accepting a first argument of type ‘State’ could be found (are you missing a using directive or an assembly reference?)

Here is my code

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class AdventureGame : MonoBehaviour {

[SerializeField] Text textComponent;
[SerializeField] State startingState;




State state;

// Start is called before the first frame update
void Start() {
    state = startingState;
    textComponent.text = state.GetStateStory();


}

// Update is called once per frame
void Update()
{
    ManageState();
}

private void ManageState() 
{
    var nextStates = state.GetNextStates();
    for (int index = 0; index < nextStates.Lenght; index++)
    {
        if(Input.GetKeyDown(KeyCode.Alpha1 + index))
        {
            state = nextStates[index];       
        }

    }
    textComponent.text = state.GetStateStory();
}

}

Hi! Welcome to the community!

When you have that kind of errors check for typos. In this case you wrote Lenght and it should be Length.

private void ManageState() 
{
    var nextStates = state.GetNextStates();
    for (int index = 0; index < nextStates.Length; index++)

Hope this helps.

1 Like

Oh My Thanks! And also my mistake. I wanna thank you one more time! Wish you have a nice day! :smiley:

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

Privacy & Terms