Static bool hasSpawned;

Hi,

A PersistentObjectSpawner is created as a scene is loaded.
So each time the script creates a “new” hasSpawned variable,
but as the variable is static, it has already been created,
so why don’t we get some error telling the variable already exists?

M. D.

Got any code so we can see what you’re asking about?

All static variables are shared by all instances of the class…
So

static bool hasSpawned;

is just the one variable, and any time hasSpawned has been set in one instance, it’s been set in all of them (because there is only one).

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms