Accessing Class Vars?

Hello,

I’m trying to access a variable inside a class, but I’m having problems:

class JetPackSettings{
   var jetPackModel : GameObject;
   var jetPackOn : boolean = false;
}

var jetSettings : JetPackSettings;

function Awake(){
   jetSettings.jetPackModel.gameObject.SetActiveRecursivelt(false);
}

The ‘jetPackModek’ won’t ‘turn off’. What am I doing wrong here?

Thanks

I don't code in javascript usually, but if its access policy is anything like C#, then the access modyfier is private by default, that is, when you write "var jetPackModel", the compiler assumes you mean "private var jetPackModel". You can't access a private class member outside the class. Add "public" in front of it and see if that helps.

1 Answer

1

public var jetPackModel : GameObject;