Quantcast
Viewing latest article 3
Browse Latest Browse All 10

Answer by karl_

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 latest article 3
Browse Latest Browse All 10

Trending Articles



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