I have an instance of a prefab. That prefab has a script attached. I want to access to a function of that script. How do I do that?
I instantiated the prefab as this: Instantiate(prefab,transform.position,Quaternion.identity);
I have an instance of a prefab. That prefab has a script attached. I want to access to a function of that script. How do I do that?
I instantiated the prefab as this: Instantiate(prefab,transform.position,Quaternion.identity);
var clone : prefabType ; //Transform, Rigidbody, whatever it is that you have for ur prefab slot eg prefab : Rigidbody ;
clone = Instantiate(prefab, yourposition, yourrotation) ;
var cloneScript : NameOfScript ;
cloneScript = clone.gameObject.GetComponent(NameOfScript) as NameOfScript ;
cloneScript.FunctionNameInItImTryingToDo() ;