- Home /
Question by
eugene7machine · Nov 29, 2015 at 09:59 AM ·
scripting problemvariables
variable from another script doesn't update
hi,
i'm working on a project with kinect for windows and unity and i've got a problem:
i use two scripts (SitToStand and test) and test uses a variable of SitToStand
void Start()
{
gameObject.GetComponent<SpriteRenderer>().sprite = sit;
showSit = GameObject.Find("SitToStand").GetComponent<SitToStand>().showIcon;
}
and
void Update()
{
showSit = GameObject.Find("SitToStand").GetComponent<SitToStand>().showIcon;
//print(showSit);
if (showSit==true)
{
gameObject.GetComponent<SpriteRenderer>().sprite = sit;
return;
}
else
{
gameObject.GetComponent<SpriteRenderer>().sprite = stand;
return;
}
}
in SitToStand, the showIcon variable is set to true in Start() and to false in Update()
but when running in unity, showSit never changes, it's always true. any idea?
thanks
Comment
Your answer
Follow this Question
Related Questions
Make variable visible in inspector 2 Answers
How do I get an object to send a value to a manager script using an ontriggerenter? 1 Answer
GUI does not work in network (but does work in scene/editor) 0 Answers
Trying to get access to variables in the editor script 4 Answers
How do I access a variable from a different scene using C#? 3 Answers