Since I'm coding for iOS, I gather I need to use static typing in my scripts. I have a function in one script which instantiates a prefab (a dust cloud). I want to retain the instantiated GameObject as a variable in the main script because I want THAT script to decide when to destroy the dust cloud. Here's a simplified version:
var dust : GameObject;
var dustCloud : GameObject; // this is the prefab
function MakeDust() {
dust = Instantiate(dustCloud, transform.position, Quaternion.identity);
}
function KillDust() {
Destroy(dust);
}
I get this error:
BCE0022: Cannot convert 'UnityEngine.Object' to 'UnityEngine.GameObject'.
The error goes away if I change the first line to:
var dust : Object;
But then, I get this error:
BCE0023: No appropriate version of 'UnityEngine.Object.Destroy' for the argument list '(Object)' was found.