- Home /
Enable script (false)
There is an enemy in my project. Enemy has a capable of changing his position like teleport. When he dies, he should not change his position. I have 2 scripts which are Teleport changing enemy's position and EnemyHelath controlling enemy's life. Teleport script see below:
IEnumerator Teleport()
{
while (! EnemyHealth.isDead)
{
// Teleport code is here
}
}
There is public static bool variable which is isDead in EnemyHeath script. When enemy dies, isDead = true, and then Teleport script checks isDead (true or false, see above code please). If it is true, teleport can go on. if it is false, teleport cannot go on.
However, in my project, even though isDead=true, enemy is changing his position. I used this technique also: GetComponent().enabled = false; But it is still running. Do you have any idea to solve this issue? IMPORTANT!!! Teleport is being run only once after enemy dies. I think my problem has to do with IEnumerator.
Your answer
Follow this Question
Related Questions
Trouble with Object Pooled Enemy Waves 0 Answers
Wait for seconds and then set a bool to true. 2 Answers
IEumerator not recognising when a bool has switched 1 Answer
public static IEnumerator 1 Answer
Smooth moving object 2 Answers