- Home /
[Answered] Error CS0019: Operator `==' cannot be applied
I've started to go into deeper coding for my game, and once I started, my first problem was making a object enable it self from a trigger. This is my Script
using UnityEngine; using System.Collections;
public class CreateObjects : MonoBehaviour {
public GameObject Prefab;
// Use this for initialization
void Start () {
if(GameObject.FindGameObjectsWithTag == ("Create")){
gameObject.SetActive(false);
}
}
void onTriggerEnter(Collision collision) {
if(GameObject.FindGameObjectsWithTag == ("Create")){
gameObject.SetActive(true);
}
}
}
I really would appreciate who ever helps me.
Answer by Positive7 · Aug 17, 2015 at 11:19 PM
using UnityEngine;
class CreateObjects : MonoBehaviour{
public GameObject Prefab;
GameObject[] taggedObj;
void Start () {
taggedObj = GameObject.FindGameObjectsWithTag("Create");
if (taggedObj != null)
{
for (int i = 0; i < taggedObj.Length; i++)
{
taggedObj[i].SetActive(false);
}
}
}
void OnTriggerEnter(Collider other) {
for (int i = 0; i < taggedObj.Length; i++)
{
taggedObj[i].SetActive(true);
}
}
}
Thanks. I really thought I had it, but I did not think it would have to go that deep.
Haven't tested the code and it might not work since if gameObject is not Active it won't get the trigger event. Let me know and I'll correct my answer.
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Parsing Error, code in android for a button 2 Answers
UNITY_MVP_MATRIX error when downloading A* Pathfinding 1 Answer