Problem creating method?

i cant understand why i cant create the method the way you did in lecture 26 first of all it doesnt create the red line under ManageStates(); that i create under the update method then when i right click on it and go to quick actions and References it doesnt show Generate method like you had in the lecture !! and i attached a photo to show you what is going on with me !!! what to do about it ?!.. im new here and im sorry if my post is not in the correct place

also i dont have the help small window you have in Microsoft visual studio helper small window that photo is from the lecture and i dont get those helper small windows on my Microsoft visual studio how can i get them ?

how%20can%20it%20be how can i get that error while i wrote the terms exactly the same like i saw in the lecture !!!

Hi @white_falcon, welcome to the community :slight_smile:

Could you post you code instead of screenshots of parts of it, it doesn’t help anyone to help you if they can’t see everything.

You can just copy/paste your code directly into the forum and then apply code formatting characters. Screenshots are however useful for error messages and editor details.


See also;

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class AdventureGame : MonoBehaviour {

    [SerializeField] Text textComponet;
    [SerializeField] State StartingState;

    State state;

    // Use this for initialization
    void Start() {
        state = StartingState;
        textComponet.text = state.GetStateStory();
       
	}
	
	// Update is called once per frame
	void Update () {
        ManageStates();
	}
    private void ManageStates()
    {
        var nextSates = state.GetNextStates();
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            state = nextStates[0];
        } 
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            state = nextSates[1];
        }
        textComponent.text = state.GetStateStory();
    }
}

here is the full code

and here is a full photo for it

Hi,

Your issues are typos.

If you look at the code you have copy and pasted in, you have spelt “component” as “componet”, you use this in the Start method, so you get away with it, but then in the ManageStates method you use spell it differently again (correctly).

You have the same issue with “nextStates” being spelt incorrectly, “nextSates” in your ManageStates method.

Again - you don’t need to add screenshots of code - they don’t really help - they are almost unreadable on mobile devices and require a lot of scrolling around - copy/paste your code and apply the code formatting characters to help us (and you) out :slight_smile:

Hope the above helps :slight_smile:

ty a lot Sir :+1:

1 Like

You’re very welcome :slight_smile:

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

Privacy & Terms