I’m making a clicker game similar to clicker heroes where you click until you kill a monster then it dies you get money then a new one spawns.
The problem I’m having is there is a long delay when it dies to when the new one is created.
Here is how I’m currently doing it. On the death animation I have the following script running.
override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
{
//animator.gameObject.transform.position= new Vector2(10000,10000);
Destroy(animator.gameObject);
}
Then in my GameManager I have
private void Update()
{
if(enemyClicking==null)
{
GameManager.instance.AddMoney(enemyClicking.enemy.goldValue);
PickEnemy();
}
}
PickEnemy chooses a random enemy and sets it up. I’ve tried moving the destroy to a different area but then the death animation doesn’t complete first. Right now there is a delay after the death animation by about a half second before the next enemy appears.
Any ideas what I should look for to fix it or what might be causing this would be great. If there are any other questions on what I did in the different areas of code I can also put that in here if it helps but everything else seems to be working and I think it has something to do with these places.