Friend developers I am in need of your help for a simple project I am working on.
I have a collection of very simple 2d shapes like triangles and cubes. Please follow my image.
What I want is when the user clicks on object A and then on object B these objects to disappear and become one object C. After that I want the user to be able to click on another object of type A or B and object C so that these two objects disappear and become object D. This could go on indefinitely
I am stuck on how to go about this and I appreciate your help and time!
This is what I have so far
public class Selector : MonoBehaviour {
public string FirstSelection;
public string SecondSelection;
public int SelectionNum;
// Use this for initialization
void Start () {
SelectionNum = 0;
}
void OnMouseDown()
{
SelectionNum += 1; //selection counter
Debug.Log("Selection " + SelectionNum);
if (SelectionNum == 1) //if this is the first selection
{
FirstSelection = gameObject.name; //assign the name of game object clicked
Debug.Log("First " + FirstSelection);
}
if (SelectionNum == 2) // if this is the second selection
{
SecondSelection = gameObject.name; //assign the name of game object clicked
Debug.Log("Second " + SecondSelection);
}
// Combinations of A + A or B + A will destroy A and B gamebojects
if (FirstSelection == "A" & SecondSelection == "A" || FirstSelection == "B" & SecondSelection == "A")
{
Destroy(GameObject.Find("A"));
Destroy(GameObject.Find("B"));
// Instantiate game object C (not there yet)
}
}
// Update is called once per frame
void Update () {
}
}