how do i change a bool variable from true to false from a different script than the variable is in?

Not sure quite how much sense that made. Sorry.
if i were to have 2 scripts. 1 called script1 the other called script2.
lets say in script1 I have a bool variable:
public bool Unity;
leys say we set it as false.
if I then wanted to change it to true From script2, how would I do this?

Referencing variables, fields, methods (anything non-static) in other script instances:

REMEMBER: it isn’t always the best idea for everything to access everything else all over the place. For instance, it is BAD for the player to reach into an enemy and reduce his health.

Instead there should be a function you call on the enemy to reduce his health. All the same rules apply for the above steps: the function must be public AND you need a reference to the class instance.

That way the enemy (and only the enemy) has code to reduce his health and simultaneously do anything else, such as kill him or make him reel from the impact, and all that code is centralized in one place.

1 Like

what are the scripts called in the first link? is script b called ScriptB or myBScript?

The class is ScriptB and the local name is myBScript.