i have a problem in this script and the problem is . . i use a yield WaitForSeconds this script is not wait . . and immediate jump onto next level how to fix this problem? script is given below
#pragma strict
var offsetx : float = 0.5 ;
var offsety : float = 0 ;
var sizex : float = 0.5 ;
var sizey : float = 1 ;
var columnsize = 2;
var rowsize = 1 ;
var columnframestart= 1;
var rowframestart = 0 ;
var totalframes = 2 ;
var framesPersecond = 3 ;
var blastPref : GameObject ;
var callWait : boolean = false ;
function Start () {
}
function Update () {
/*
var offset = Vector2( offsetx , offsety );
var size = Vector2( sizex , sizey );
renderer.material.mainTextureOffset = offset;
renderer.material.mainTextureScale = size;
*/
var anim = this.gameObject.GetComponent(sprite);
anim.sprite( columnsize , rowsize , columnframestart , rowframestart , totalframes , framesPersecond );
}
function OnTriggerEnter(col : Collider)
{
if( col.tag == "Player" )
{
Debug.Log("collide with mine");
Destroy(this.gameObject);
Instantiate( blastPref , transform.position , Quaternion.identity);
blastPref.transform.Rotate(90 ,0 ,0);
Destroy(col.gameObject);
callWait = true ;
yield WaitForSeconds(2);
Application.LoadLevel(0);
}
}