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