Quantcast
Channel: Answers for "Global variables questions"
Viewing all articles
Browse latest Browse all 10

Answer by karl_

$
0
0
You can access local variables by creating an instance of the script. As an example, lets say you have someVariable located in scriptA, which is attached to gameObjectA. You want to access it from scriptB, which is attached to gameObjectB. Within scriptB: function Update() { // Find the gameobject that scriptA is attached to var instanceGO : GameObject.Find("gameObjectB"); // Create an instance of the script var instanceScript : scriptA = instanceGO.GetComponent("scriptA"); // Set someVariable to 0. instanceScript.scriptA.someVariable = 0; }

Viewing all articles
Browse latest Browse all 10

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>