Hi, im fairly new to Unity and coding in general (JS in this case). I have a problem trying to invoke a function from a script that is attached a game object in my scene. This game object was carried over from a previous scene using DontDestroyOnLoad. The game object and attached script (MainMenu) stay intact and carry over when I load a new scene just fine, but I still get this error when trying to invoke SetGameVolume (which is defined in MainMenu.js):
*An instance of type 'MainMenu' is required to access non static member 'SetGameVolume':*
**the code im using to invoke:**
function OnTriggerEnter (info : Collider)
{
if (info.tag == "Player")
{
GameMaster.currentScore += coinValue;
MainMenu.SetGameVolume (0);
}
}
**the function as defined in MainMenu.js**
function SetGameVolume (vol : float) {
music.volume = vol;
}
MainMenu is in the scene... its attached to the game object (which i carried over using DontDestroyOnLoad) and is in the assets folder anyway. I tried setting the variables and functions to static as well but no luck. This seems like a very simple problem, help??
↧