- Home /
This question was
closed Nov 30, 2011 at 03:18 AM by
Bunny83 for the following reason:
http://answers.unity3d.com/questions/190223/using-coroutines.html
Question by
JDMorrison75 · Nov 30, 2011 at 03:07 AM ·
coroutines
problems with coroutines
trying to use coroutine but it only works once. then seems to not go back to the start function all collision stops after it works once here is the script using C#
// check to see if enemy collides with the player void OnTriggerEnter(Collider otherObject) { if (otherObject.tag == "enemy") {
player.Lives--;
Enemy enemy = (Enemy)otherObject.gameObject.GetComponent("Enemy");
enemy.setpositionandspeed();
StartCoroutine(Destroyship());
}
}
//get ship to explode and reappear
IEnumerator Destroyship()
{
Instantiate(explosionprefab, transform.position, Quaternion.identity);
gameObject.renderer.enabled = false;
transform.position = new Vector3 ( 0f, transform.position.y, transform.position.x);
yield return new WaitForSeconds(1.5f);
gameObject.renderer.enabled = true;
}
}
Comment
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Can i check if a coroutine is running? 8 Answers
NullReferenceException in StartCoroutine 1 Answer
Game architecture problem 0 Answers