Enable a component OnTriggerEnter.

hey guys
(Firstly I have watched the Unity Guides I am just stuck)

I am trying to create a trigger which will enable a script on a gameobject when the trigger and a unit collide

using UnityEngine;
using System.Collections;

public class EnableComp : MonoBehaviour
{
    public GameObject mySpot;

    void Start()
    {
        mySpot = GetComponent<BUILDPLACE> ();
    }

    void OnTriggerEnter(Collider co)
    {
        mySpot.enabled = !mySpot.enabled;
    }

}

Am I using the wrong script cause it just comes up that

‘’ Assets/Scripts/EnableComp.cs(18,32): error CS1061: Type UnityEngine.GameObject' does not contain a definition for enabled’ and no extension method enabled' of type UnityEngine.GameObject’ could be found (are you missing a using directive or an assembly reference?) ‘’

THANNNKKSSSSSS

public GameObject mySpot;

should be

public BUILDPLACE mySpot;

just to add, GameObjects use the setActive approach, components use the enabled approach as Daniel says :slight_smile:

Okay so Now Im using

{
    public BUILDPLACE mySpot;

    void Start()
    {
        mySpot = GetComponent<BUILDPLACE> ();
    }

    void OnTriggerEnter(Collider co)
    {
        if (co.tag == ("Friend")) {
            mySpot.enabled = !mySpot.enabled;
        }
    }

}

This is set to a box collider and references the GameObjectwith the script ‘‘BUILDPLACE’’ but when the friendly units interact with it, it just says ‘‘detected object’’ but doesn’t enable the script on the GameObject.