i want to enable all the game objects with tag “enable” when i do GameObjects,FindwithTags i dont wave the option to .SetActive() any one point me in the right direction please
public string obl;
private GameObject A;
void Start () {
}
void OnTriggerExit (Collider other){
if (other.gameObject.tag == “player”) {
A = GameObject.FindGameObjectsWithTag (obl);
A.SetActive (true);
}
There’s a sticky post at the top of this subforum explaining how to use code tags to format code properly on the forum. Please use these when posting code.
Whenever you search for more GameObjects than one, as with FindGameObjectsWithTag, what you get back is an array(GameObject[ ]). You must iterate/loop through the array and call SetActive on one element at a time.
GameObject does not have definition for set active only gameObject have ths defination and thanks for pointing out how to post code can any one solve this problem
using UnityEngine;
using System.Collections;
public class objectenabler : MonoBehaviour {
// Use this for initialization
public string obl;
private GameObject []A;
void Start () {
}
void OnTriggerExit (Collider other){
if (other.gameObject.tag == "player") {
A = GameObject.FindGameObjectsWithTag (obl);
foreach (GameObject B in A) {
A = gameObject.SetActive (true);
}
}
}
// Update is called once per frame
void Update () {
}
}