- Home /
Why a public varibale is not accsible inside Update() ?
using UnityEngine;
using System.Collections;
public class objectControl : MonoBehaviour {
public char slected_item = 'F';
public int selected_model = 0;
public GameObject f,o,d;
// Use this for initialization
void Start () {
f = GameObject.Find("f");
o = GameObject.Find("o");
d = GameObject.Find("d");
}
// Update is called once per frame
void Update () {
if (Input.GetKey(KeyCode.F)){
selected_item = 'F';
doSelectedAnimation();
}
}
void doSelectedAnimation(){
iTween.MoveTo(f,iTween.Hash("y",-3,"time",4));
}
}
I get the following error
Assets/Scripts/objectControl.cs(20,25): error CS0103: The name `selected_item' does not exist in the current context
Comment
Best Answer
Answer by syclamoth · Oct 04, 2011 at 08:14 AM
You mis-spelled selected_item back when you defined it! It says "slected_item" instead of "selected_item"!
Your answer
Follow this Question
Related Questions
GUI Variables doesn't update C# 0 Answers
summing up items price in runtime 1 Answer
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers