Hey there! We are almost done with our 2D game but i tried to create a variable that will store a gameobject array and then use it in an if statement inside the OnMouseDown function but it does not work.So we got 2 objects a blue dot and a red dot.I want my script to do this : when you click on the red dot(tagged"Red") you lose and it loads the MainMenu level or if you click on the blue dot(tagged"Blue") you win and it loads the next level.I think an if statement will do but looks like i got something wrong so if you can help me it would be great!Here is my code :
using UnityEngine;
using System.Collections;
public class OnClick : MonoBehaviour {
private GameObject prefabs;
void OnMouseDown()
{
prefabs = GameObject.FindGameObjectsWithTag ("Red");
if (prefabs = GameObject.FindGameObjectsWithTag ("Red")) {
Application.LoadLevel("Main Menu");
}
}
}
Then i get an error that a gameobject cannot be set to a bool value.Please help us finish this game!