- Home /
Solved-Change a Variable in another script with flashplayer build
In my last unity webplayer project this code worked great to change variables in another script. now that i am trying to build for a flash player instead of the webplayer, I get a compiler error on the last line that i am pasting below. it gets the component but i cant change the variable.
var brain:Component;
brain=GetComponent("brain");
brain.answer1=5;
the Compiler error is:
Assets/todds scripts/camera.js(3,7): BCE0019: 'answer1' is not a member of 'UnityEngine.Component'.
Can someone provide a working code to change a variable in another script when building for the flash player? javascript please? thanks:)
Answer by toddisarockstar · Feb 16, 2015 at 07:20 PM
well i am answering my own question, its seems funny to repeat like this but its the only way i could get this to work at the top of my script where i wanted it:
thingy:GameObject;
thingy=GameObject.Find("George");
var otherscript: walk = thingy.GetComponent(walk);
otherscript = thingy.GetComponent(walk);
and if the game object named "George" has a script attached called "walk",you now can change the variable in the other script with :
otherscript.somevariable=true;
Your answer
Follow this Question
Related Questions
static vars in another script not changing? 1 Answer
Change a value on a disabled gameobject 2 Answers
Build for Flash 10.1 Player 1 Answer
"Script2" will not update variable in "Script1" (No error messages) 1 Answer
Cannot Edit variables? 1 Answer