This is werid.

Hello all.
I used this script off one of the scripting places and it works fine. Unity - Scripting API: Object.Destroy

// Starting in 2 seconds.
// a projectile will be launched every 0.3 seconds
var projectile : Rigidbody;
InvokeRepeating("LaunchProjectile", 2, 0.3);
function LaunchProjectile () {
    instance = Instantiate(prefab);
    instance.velocity = Random.insideUnitSphere * 5;
}

Now I changed it to my needs and this is what I had.

// Takes 2 seconds to delete. 
// If you click "Mouse1" it wont destroy
var projectile : Rigidbody;
InvokeRepeating("LaunchProjectile", 2,0.5);

function Update() {
	if (Input.GetButton ("Fire1")) {
		CancelInvoke();
		print("You Cancel'd");
		}
	}
	
function LaunchProjectile () {
	Destroy (gameObject);
		print("Started");

}

It jumps straight to the CancelInvoke and prints “You Cancel’d”

Whats the problem. Or is it just javascript hates me lol

  • James

Does it happen as soon as the game starts up in the editor? I know I’ve had issues where when I press the “play” button in the editor my scripts pick up on the fact that my mouse is already down.

EDIT: btw, “cancelled” :smile:

Ah! Silly Unity. I right clicked it and it did not skip!

Thanks a lot! well LOADS!

-Jim

P.S Unity please make it so the play button does not react when you press it. Thanks!

You can use the menu/keyboard shortcuts instead of the play button if you suspect it’s an issue. Edit → Play (Ctrl+P)