The script below is a simple bomb explosion script triggered at a certain point during my game. I want there to be two different sprites appearing before the bomb detonates.
The value countdownTime won’t impact the changes in sprites until it goes above 1f. I’d like to have the changes happen with less than a second between them so this is rather irritating. Can someone explain what is happening here?
void Explode()
{
if (setCountdown == false)
{
countdownTime += Time.time;
setCountdown = true;
}
if (Time.time > countdownTime)
{
spriteRenderer.sprite = boomb;
}
if (Time.time > countdownTime * 2)
{
spriteRenderer.sprite = boombTwo;
}
if (Time.time > countdownTime * 3)
{
if (exploded == false)
{
Instantiate(topRightFrag, topRight.transform.position, topRight.transform.rotation);
Instantiate(topLeftFrag, topLeft.transform.position, topLeft.transform.rotation);
Instantiate(bottomRightFrag, bottomRight.transform.position, bottomRight.transform.rotation);
Instantiate(bottomLeftFrag, bottomLeft.transform.position, bottomLeft.transform.rotation);
exploded = true;
}
Destroy(gameObject);
}
}