Stop instance

Lads,

I’m trying to cancel an instantiation. Currently the invoke continues to instance the gameobject after ‘towerdamage’ == 0. Here’s my script:

using UnityEngine;
using System.Collections;

public class Strike_Details : MonoBehaviour {


		
		public float strikeSpeed = 1f;
		Tower_Damage script;
		
		void Start()
		{
			Invoke ("SpawnObject", strikeSpeed);
			script = gameObject.GetComponent<Tower_Damage>();
		}
		
		void SpawnObject()
		{
			Instantiate(gameObject, transform.position, transform.rotation);
			Destroy (gameObject);
		}
		void update ()
		{
		if (script.towerDamage == 0)CancelInvoke (gameObject);
		}
	}

Any ideas?

Stef

CancelInvoke() needs to have the method name passed to it, not the gameObject

see here