How to disable only a part of the script and not entire script? For instance if I wanted to disable a public void Spawner() how would I do that?
I know how to access it, but dont know how to disable “ONLY” Spawner() function within another script. I also know how to disable an entire sript, but no luck in trying to disable only a small part of another script.
So what i need to disable is only “gm2.Spawner()”:
public class Player : MonoBehaviour
{
private GameManager2D gm2;
private bool isSpawned;
void Start ()
{
gm2 = FindObjectOfType<GameManager2D>();
}
void OnTriggerEnter2D(Collider2D col)
{
if (col.CompareTag ("Horse")) {
if (!isSpawned) {
isSpawned = true;
gm2.enabled = true;
` gm2.Spawner();`
}
}
void OnTriggerExit2D(Collider2D col)
{
isGrounded = false;
{
if (col.CompareTag ("Horse")) {
if (isSpawned) {
isSpawned = true;
Destroy (hor);
/*
//This is what i wish to get DISABLED
//gm2.Spawner ();
//gm2.GetComponent<Spawner>().enabled = false;
//THIS ISNT WORKING, but this is what i would like to have
*/
Debug.Log ("Destroy HOR PLZ");
}
}
}
Please if anyone can help me with this problem, because I been struggling with this problem for months now. Thank you in advance!