Accesing bools from a script with inactive object

Hi

So I have this project called BattleCore, and I made a character Thor that can throw his hammer.
I made more parts of this character like torso and legs, and I need to acces somme booleans to specify somme things , and I just dont seem to be able to get them, I used somme FindObjectOfType before and it worked not on bools but other variables and now when I try the syntax it doesnt work it pops this error message :

NullReferenceException : Object reference not set to an instance od the object.

I need to check this bools on the body script at the moment of instantiation of the Hammer in a void function.

I need to acces the bools from the script “Mjolnir” to script “Body”.

Any help is deeply apreciated <3.

I think this should allow you to access your script.

// add this at the top with your other variables and bools
GameObject objectWithScript;

// add this in the Start function
objectWithScript.GetComponent<Mjolnir>();

// add this or whatever reference you need to do want you want 
//in the rest of the script
objectWithScript.Mjolnir.whateveryouwant = whateveryouneed;

let me know if this worked or if I’m just way off from what you need lol

1 Like