I want to disable a script attached to a camera using a script attached to the player
using UnityEngine;
using System.Collections;
public class MainRestart : MonoBehaviour {
private BlockSizeAndPosition DisableSpawningBlocks;
private PlayerMovement DisablePlayerMovement;
private MainRestart ThisScript;
public GameObject DisableCameraFollow;
void Awake() {
DisableSpawningBlocks = GetComponent<BlockSizeAndPosition>();
DisablePlayerMovement = GetComponent<PlayerMovement>();
DisableCameraFollow = GetComponent<CameraFollow>();
ThisScript = GetComponent<MainRestart>();
DisableCameraFollow = GameObject.FindWithTag ("MainCamera").GetComponent<CameraFollow>(); //I'm trying to get the CameraFollow script using this line
}
void OnTriggerEnter2D(Collider2D OtherObject) {
if(OtherObject.gameObject.CompareTag("Enemy")) {
DisableSpawningBlocks.enabled = false;
DisablePlayerMovement.enabled = false;
DisableCameraFollow.enabled = false; //It won't let me use the "enabled"
Destroy (gameObject);
ThisScript.enabled = false;
}
}
void Update() {
if (transform.position.x > 2.62f || transform.position.x < -2.62f) {
DisableSpawningBlocks.enabled = false;
DisablePlayerMovement.enabled = false;
DisableCameraFollow.enabled = false; //Same problem with "enabled" here
Destroy (gameObject);
ThisScript.enabled = false;
}
}
}
