Here is my code:
IEnumerator blinkTime () {
if (blinking == true) {
blinkTimeOn = true;
while (blinkTimeOn == true) {
renderer.enabled = false;
yield return new WaitForSeconds (1f);
blinkTimeOff = true;
blinkTimeOn = false;
}
while (blinkTimeOff == true) {
renderer.enabled = true;
yield return new WaitForSeconds (1f);
blinkTimeOn = true;
blinkTimeOff = false;
}
}
}
I'm trying to make an object's renderer be enabled for a second then disabled for a second and this will repeat until blinking is set to false.
What exactly am I doing wrong here?
Edit: I should point out that I have "blinkTime" being called here:
void OnTriggerEnter(Collider otherObject) {
if (otherObject.gameObject.CompareTag ("Enemy")) {
playerLives--;
Timer = Time.time;
blinking = true;
blinkTime();
if (playerLives < 1) {
Destroy(this.gameObject);
}
}
↧