So what im trying to do is after the destroy player function was called I want my player to play an animation and then to delete the object and the animation that its played.At the moment it plays the animation and then creates a new player object ,but the animation is still on screen and its not destroyed.Please help me.
function destroyPlayer(dpos : Vector3)
{
var player1 : GameObject = Instantiate(playerDeathObj,dpos,playerDeathObj.transform.rotation) as GameObject;
player1.animation["death"].speed = 3.5;
yield WaitForSeconds(0.5);
Destroy(player1);
}
After running a Debug.Log after the WaitForSeconds i noticed that destroy player is not even reached but if i try to put it on the Update function it destroys my new object.I really dont know what to do.Help me please.
also if i remove the yield WaitForSeconds it destroys it like it should but the animation is not played anymore...
– RedDevil