Time.time value carrying over between timers
I am currently working on a game inspired by fnaf 1. I have my enemy set up to generate a few random numbers and use those to decide where to move. I also have a delay for how long the enemy must wait before teleporting again which is written:
public IEnumerator StartTimeCheckHouseMove() { yield return new WaitForSeconds(2); Night1HouseMoveDelayTime = Time.time; }
if(EnemyAtHouse.activeInHierarchy == true) { StartCoroutine(StartTimeCheckHouseMove()); }
if(EnemyAtHouse.activeInHierarchy == true && Night1MoveDelay - Night1HouseMoveDelayTime <= 0)
I have if statements like this one created for each location and it had been working but i noticed that when the enemy switches locations, it transfers over the value from the last timer to the new one and keeps the value stored in the last float for the timer. Eventually this makes the enemy infinitely teleport between all of the locations. Is there any way i can clear the float for each timer when the enemy teleports to a new location?