My underwater script how do I check if a gameobject is active?
So I'm creating a underwater script for my survival game and for the torch when I go underwater I want the torch to despawn.... this part of the script works but my only issue is, is checking if the torch was already active so when I come out of the water it'll set it back to active if it was previously active before going in the water...
function SetNormal ()
{
RenderSettings.fogColor = normalColor;
RenderSettings.fogDensity = 0.002f;
if(wasactive = true) {
torch.SetActive(true);
}
}
function SetUnderwater ()
{
if(torch.activeInHierarchy) {
wasactive = true;
}
else {
wasactive = false;
}
RenderSettings.fogColor = underwaterColor;
RenderSettings.fogDensity = 0.1f;
myParticles.enableEmission = true;
myParticles.Play();
torch.SetActive(false);
}
Here's a short snippet of the code I'm working with the other 50 lines aren't going to attribute to the fixing of this since this is the only thing dealing with my problem
so explain simply when do you want to activate & deactivate torch firstly & how do you call thees tow functions is it automatic or input ?
Your answer
Follow this Question
Related Questions
Set Active Random GameObject from array (JavaScript) 1 Answer
Wat for seconds not working! HELP 0 Answers
Change the active value quickly? 1 Answer
How get position from a game object? 5 Answers