Hello,
Can someone please tell me what I am doing wrong in this statement?
public GameObject arrayAll={GameObject.FindGameObjectsWithTag(“car”), GameObject.FindGameObjectsWithTag(“trafficlight”), GameObject.FindGameObjectsWithTag(“zebracrossing”)};
Hello,
Can someone please tell me what I am doing wrong in this statement?
public GameObject arrayAll={GameObject.FindGameObjectsWithTag(“car”), GameObject.FindGameObjectsWithTag(“trafficlight”), GameObject.FindGameObjectsWithTag(“zebracrossing”)};
@meat5000 that was the line i got an error. @frarees I tried replacing with FindGameObjectwithTag. This is my entire code.
using UnityEngine;
using System.Collections;
using System.Collections.Generic ;
using System.Linq ;
public class repl_two : MonoBehaviour {
public GameObject arrayAll;
public float percentage;
public float area;
public float height;
public float width;
public bool carnear=false;
public bool trafficnear=false;
public bool zebranear=false;
public bool carseen= false;
public bool trafficseen= false;
public bool zebraseen= false;
public float cardist;
public float trafficdist;
public float zebradist;
public float carcounter=0.0f;
public float trafficcounter=0.0f;
public float zebracounter=0.0f;
public bool moving=false;
public Vector3 previous;
public float vel;
public float speed;
void Update () {
arrayAll = {GameObject.FindGameObjectWithTag("car"),GameObject.FindGameObjectWithTag("car1"), GameObject.FindGameObjectWithTag("trafficlight"),GameObject.FindGameObjectWithTag("trafficlight1"), GameObject.FindGameObjectWithTag("zebracrossing"),GameObject.FindGameObjectWithTag("zebracrossing1")};
for(int i=0; i<arrayAll.Length; i++){
if ((arrayAll<em>.CompareTag ("car")|| arrayAll_.CompareTag("car1")) && arrayAll*.renderer.isVisible) {*_</em>
_ vel = ((arrayAll*.transform.position - previous).magnitude) / Time.deltaTime;*_
_ previous = arrayAll*.transform.position;*_
* moving = true;*
* }*
* }*
* for(int i=0; i<arrayAll.Length; i++){*
if (arrayAll_.CompareTag (“car”)||arrayAll*.CompareTag(“car1”)) {*_
_ cardist = Vector3.Distance (arrayAll*.transform.position, Camera.main.transform.position);
Camera.main.transform.position);*_
_ if (arrayAll*.renderer.isVisible && cardist <= 5) {
carnear = true;*_
* } else {*
* carnear = false;*
* }*
* }*
* }*
* for(int i=0;i<arrayAll.Length;i++){*
if (arrayAll_.CompareTag (“trafficlight”)|| arrayAll*.CompareTag(“trafficlight1”)) {*_
_ trafficdist = Vector3.Distance (arrayAll*.transform.position, Camera.main.transform.position);*_
_ if (arrayAll*.renderer.isVisible && trafficdist <= 5) {
trafficnear = true;*_
* } else {*
* trafficnear = false;*
* }*
* }*
* }*
* for(int i=0; i<arrayAll.Length;i++){*
if (arrayAll_.CompareTag( “zebracrossing”)|| arrayAll*.CompareTag(“zebracrossing1”)) {
zebradist = Vector3.Distance (arrayAll.transform.position, Camera.main.transform.position);*_
_ if (arrayAll*.renderer.isVisible && zebradist <= 5) {
zebranear = true;
//Debug.Log (“target is close”);
} else {
zebranear = false;
}
}
}*_
* for(int i=0; i<arrayAll.Length;i++){*
if ((arrayAll.CompareTag(“car”)||arrayAll_.CompareTag(“car1”)) && arrayAll*.renderer.isVisible) {*_
* carcounter += Time.deltaTime;*
_ if (carcounter >= 3.0f && arrayAll*.renderer.isVisible) {
carseen = true;*_
* carcounter = 0.0f;*
* }*
* else {*
* carseen = false;*
* carcounter = 0.0f;*
* }*
* }*
* }*
* for(int i=0;i<arrayAll.Length;i++){ *
if (arrayAll_.CompareTag (“trafficlight”)|| arrayAll*.CompareTag(“trafficlight1”)) {*_
_ if (arrayAll*.renderer.isVisible) {
trafficcounter += Time.deltaTime;
if (trafficcounter >= 3.0f && arrayAll.renderer.isVisible) {
trafficseen = true;*_
* trafficcounter = 0.0f;*
* }*
* else {*
* trafficseen = false;*
* trafficcounter = 0.0f;*
* }*
* }*
* }*
* }*
* for (int i=0; i<arrayAll.Length; i++) { *
if ((arrayAll.CompareTag(“zebracrossing”)||arrayAll_.CompareTag(“zebracrossing1”)) && arrayAll*.renderer.isVisible) {
zebracounter += Time.deltaTime;
if (zebracounter >= 3.0f && arrayAll.renderer.isVisible) {
zebraseen = true;*_
* zebracounter = 0.0f;*
* } *
* else {*
* zebraseen = false;*
* zebracounter = 0.0f;*
* }*
* }*
* }*
* }*
void OnGUI(){
* GUI.Box (new Rect (100, 0, 250, 250), “Perception”);*
* for(int i=0; i<arrayAll.Length; i++){ *
if ((arrayAll.CompareTag(“car”)|| arrayAll_.CompareTag(“car1”)) && vel >= 0.1 && arrayAll*.gameObject.renderer.isVisible) { *_
* GUI.Box (new Rect (100, 0, 250, 250), "
car moving at speed of " + vel);*
* }*
* }*
* for(int i=0; i<arrayAll.Length; i++){*
if ((arrayAll.CompareTag (“car”)||arrayAll_.CompareTag(“car1”)) && carnear == true && cardist <= 5 && arrayAll*.gameObject.renderer.isVisible ) {*_
_* GUI.Box(new Rect(100,0,250,250),"
car is close target"+cardist); }
}*_
* for(int i=0;i<arrayAll.Length; i++){ *
if ((arrayAll.CompareTag(“trafficlight”)|| arrayAll_.CompareTag(“trafficlight1”)) && trafficnear == true && trafficdist <= 5 && arrayAll*.renderer.isVisible ) {
GUI.Box(new Rect(100,0,250,250),"
trafficlight is close target"); }
}*_
* for(int i=0; i<arrayAll.Length; i++){*
if ((arrayAll.CompareTag(“zebracrossing”)|| arrayAll_.CompareTag(“zebracrossing1”)) && zebranear == true && zebradist <= 5 && arrayAll*.renderer.isVisible ) {
GUI.Box(new Rect(100,0,250,250),"
zebracrossing is close target"); }
}*_
* for(int i=0; i<arrayAll.Length; i++){ *
if ((arrayAll.CompareTag(“car”)||arrayAll_.CompareTag(“car1”)) && carseen == true && arrayAll*.renderer.isVisible) {
GUI.Box (new Rect (100, 0, 250, 250), "
car viewed more than 3 sec");
}}*_
* for(int i=0; i< arrayAll.Length; i++){*
if ((arrayAll.CompareTag(“trafficlight”)|| arrayAll.CompareTag(“trafficlight1”)) && trafficseen == true && arrayAll_.renderer.isVisible /&&trafficcounter >2.5f/) {
* GUI.Box (new Rect (100, 0, 250, 250), "
trafficlight viewed more than 3 sec");
}}*_
* for(int i=0; i<arrayAll.Length;i++){*
if ((arrayAll.CompareTag(“zebracrossing”)|| arrayAll_.CompareTag(“zebracrossing1”)) && zebraseen == true && arrayAll*.renderer.isVisible) {
GUI.Box (new Rect (100, 0, 250, 250), "
zebra viewed more than 3 sec");
}}
}*_