- Home /
I had not given the appropriate name to the script
Script is giving error that no MonoBehaviour scripts in file
Hello all, I have this script that you attach to a gameObject, a prefab which is being instantiated, once the deactivationPoint's y-position has surpassed this gameObject's y-position the gameObject is supposed to deactivate. This is supposed to be used for object pooling. However I keep getting the error: No Monobehavior scripts in file, or their names do not match the file name. I cant figure out whats wrong with this script, or maybe Im doing something Im not supposed to? Sorry if I havent explained my question clearly. Any and all help will be greatly appreciated Thanks
// used to hold the DeactivatorPoint
private UnityEngine.GameObject deactivationPoint;
void Start()
{
deactivationPoint = UnityEngine.GameObject.Find("DeactivatorPoint");
}
// Update is called once per frame
void Update () {
// if the object's y value is less than the obstacle deactivators y value deactivate it so it can be used again later
if (gameObject.transform.position.y < deactivationPoint.gameObject.transform.position.y)
{
gameObject.SetActive(false);
}
}
Follow this Question
Related Questions
How to reactivate items ? 4 Answers
How to make Set Active true when scene loads 1 Answer
Simple GameObject Hide/Unhide with bool!!! 0 Answers
Panel GameObject not activating 0 Answers
Panel GameObject not activating when called from another script 1 Answer