- Home /
Question by
onguarde · Nov 04, 2012 at 03:08 PM ·
gameobjectinstantiateclass
Unable to Call Instantiate in Class Member Function
Hi!
The following javascript is attached to a gameObject.
var instance : GameObject;
class eg_class {
function eg_func(){
var thePrefab : GameObject;
instance = Instantiate(thePrefab);
}
}
Error,
Unknown identifier: 'instance'. Unknown identifier: 'Instantiate'.
Questions, 1) Why is it that "instance" cannot be accessed within a class? Isn't it supposed to be a public variable?
2) "Instantiate" function works in Start()/Update() root functions. Is there a way to make it work from within member functions?
Thanks in advance!
Comment
Your answer