As the title states I just need a simple explanation. I understand the logic behind coroutines i just have no idea on how to implement it. I have a freeze tower (for TD game) that when it attacks an enemy the enemy freezes. In what part of the script would i need to add the coroutine? Also, do i need to add a triggered event script to access the coroutine? I have very little knowledge on how to script. Most of what i know has been through the use of tutoriols and forums. Any help would be greatly appreciated.
Thanks.
Below is my actual script
var myCashValue: int = 50;
var speedRange : Vector2 = Vector2(7.0, 10.0);
var heightRange : Vector2 = Vector2(7.0, 10.0);
var walk : AnimationClip;
var death : AnimationClip;
var health : float = 100;
var explosionEffect : GameObject;
private var forwardSpeed : float = 100;
private var maxHealth : float = 10.0;
var levelMaster : LevelMaster;
function Start ()
{
levelMaster = GameObject.FindWithTag(“LevelMaster”).GetComponent(LevelMaster);
maxHealth = health;
animation.Play(“walk”);
forwardSpeed = Random.Range(speedRange.x, speedRange.y);
transform.position.y = Random.Range(heightRange.x, heightRange.y);
forwardSpeed*= levelMaster.difficultyMultiplier;
health*= levelMaster.difficultyMultiplier;
maxHealth*= levelMaster.difficultyMultiplier;
}
function Update () {
transform.Translate(Vector3.forward * (forwardSpeed * Time.deltaTime));
}
function TakeDamage(damageAmount : float)
{
health -= damageAmount;
var helathPercent = health/maxHealth;
if(health <= 0)
{
Explode();
return;
}
}
function Explode()
{
animation.Play(“death”);
yield WaitForSeconds(animation[“death”].length);
levelMaster.cashCount+=myCashValue;
levelMaster.enemyCount–;
levelMaster.scoreCount+=(maxHealth+forwardSpeed*levelMaster.difficultyMultiplier);
levelMaster.UpdateGUI();
Instantiate(explosionEffect, transform.position, Quaternion.identity);
Destroy(gameObject);
}