- Home /
Question by
martinhalldin · Nov 16, 2012 at 06:29 PM ·
loadingaccesswait
Accessing scripts from another script
I'm trying to make a game where the level is randomly generating and i want to make my character "wait" till the loading has reached 100%, but i couldn't figure out how so i was wondering of there's a way to access a line or multiple lines of codes from a completely different script
Comment
you have a long and fully explained tutorial here:
http://unitygems.com/script-interaction-tutorial-getcomponent-unityscript/
Answer by Kiloblargh · Nov 16, 2012 at 06:40 PM
var otherScript : OtherScript;
var someValue : int = 42;
function Awake ()
{
otherScript = GameObject.FindWithTag("OtherObject").GetComponent.<OtherScript>();
}
function Start ()
{
otherScript.aVariable = someValue;
otherScript.DoSomething();
}
I'm new to scripting so I'm just wondering if there's anything I have to do like what to remove and stuff like that...
Well, I modified your answer but I realized it is not so right...
GetComponent<Script>();
is for C#, it should be
GetComponent(Script);
Your answer
![](https://koobas.hobune.stream/wayback/20220613084004im_/https://answers.unity.com/themes/thub/images/avi.jpg)