React to something entering a trigger
private void OnTriggerEnter(Collider other){
Debug.Log("Fish entered, name is:");
Debug.Log(other.gameObject.name);
}
GetComponent on itself
void Start(){
GetComponent<CatScript>().healthPoints = 5;
GetComponent<CatScript>().Meow();
}
GetComponent on other GameObject
public GameObject dog;
void Start(){
dog.GetComponent<DogScript>().healthPoints = 5;
dog.GetComponent<DogScript>().Bark();
}
Making variables/functions accessible in DogScript
public int healthPoints = 1;
public void Bark(){
Debug.Log("Dog is barking!");
}
Switching Scenes
void Start(){
UnityEngine.SceneManagement.SceneManager.LoadScene("SceneName");
}