Question by
tutaBugarin · Oct 07, 2020 at 08:19 PM ·
scripting problemnoob
My coroutine script isn't working, it has no errors
I don't have any errors, that confuses me. I tried looking it up, nothing helped. Sorry if this is not a relevant question. Btw here's the portion of the code that caused trouble:
bool CanGoInvisible;
bool InvisibleCooldownOver;
public MeshRenderer Renderer;
IEnumerator goVisible()
{
for (float ft = 0f; ft <= 1; ft += 0.1f)
{
InvisibleCooldownOver = true;
Color c = Renderer.material.color;
c.a = ft;
Renderer.material.color = c;
yield return null;
}
}
IEnumerator InvisibleTime()
{
yield return new WaitForSeconds(3);
}
IEnumerator GoInvisible()
{
for (float ft = 1f; ft >= 0; ft -= 0.1f)
{
InvisibleCooldownOver = false;
InvisibleTime();
Color c = Renderer.material.color;
c.a = ft;
Renderer.material.color = c;
yield return null;
Debug.Log("It worked!");
}
}
void Update()
{
if (Input.GetKey(KeyCode.LeftShift))
{
StartCoroutine("GoInvisible");
}
}
Comment
Your answer
Follow this Question
Related Questions
How do I make the player character take damage while standing still? 1 Answer
Scripting Errors 1 Answer
Using OnCollisionEnter with 3 objects 1 Answer
Script not doing anything 1 Answer
Adding new spawned objects to a list? 0 Answers