Hi, I’ve made a script that I use on triggers to spawn/despawn additional game elements when you walk in or out of it, depending on the settings you change in the Inspector.
But I’m not able to understand what’s wrong with my syntax.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnSomeStuff : MonoBehaviour
{
void Start()
{
this.audioDevice = base.GetComponent<global::UnityEngine.AudioSource>();
}
void Update()
{
arrayPosition = 0;
}
void OnTriggerEnter(Collider other)
{
if(!this.ignoreEnter & other.tag == "Player")
{
if(this.despawnOnEnter)
{
this.Objects.SetActive(false);
}
else
{
this.Objects.SetActive(true);
}
}
}
void OnTriggerExit(Collider other)
{
if(!this.ignoreExit & other.tag == "Player")
{
if(this.spawnOnExit)
{
this.Objects.SetActive(true);
}
else
{
this.Objects.SetActive(false);
}
}
}
public GameControllerScript gc;
public bool despawnOnEnter;
public bool spawnOnExit;
public bool ignoreEnter;
public bool ignoreExit;
private AudioSource audioDevice;
public static int arrayPosition = 0;
public GameObject[] Objects;
}
I get errors saying
‘GameObject’ does not contain a definition for ‘SetActive’ and no accessible extension method ‘SetActive’ accepting a first argument of type ‘GameObject’ could be found (are you missing a using directive or an assembly reference?)
Help would be greatly appreciated!