I have script attached to gameObject. But I want to take function DisappearNow() and add as separate script. It should be simple but I still puzzled. How do I call to it from main script? Do I have (is it a must) to create new class or do i just copy DisappearNow function and add? When I create new script it creates new class. But do I have to create a new class for every little snippet of code? So if i have 20 functions, there will be 20 classes?
I tried to look through Unity scripting videos but can not find answer.
Could someone give example?
public class MainScriptUnitWarior: MonoBehaviour {
void Start () {
}
void DisappearNow() {
Destroy(this.gameObject);
}
}
Thank you!