Skip to main content

Posts

Showing posts with the label calling on another script

Referencing another script..

So, here's how it's done. function addingExp(){     var level = gameObject.Find("Player").GetComponent(Level);     level.experience +=50; } Explanation: gameObject.Find("Player")  Finds the object the script it attached to. Player is the name of the object, note that the name has to be in quotations. GetComponent(Level) Finds the name of the script. level.experience +=50; level is calling the variable that we just set above, experience is a variable within the script that were calling on in the code.