For some reason my tag won't change to other falling when the other is other falling 2.

public Color[] color = new Color[5];
    public int puyoColor = 4;
    public bool pieceRotate = true;
    public bool pieceFall = false;
    public PuyoScript puyoScript;
    public GameObject puyoSpawn;
    public SpawnPuyoScript spawnPuyoScript;
    public Customization customization;
    int colorCount = 1;
    List<int> colors = new List<int>();
    public GameObject puyo1;
    public int randomColor;
    public bool randomize;
    void Start()
    {
        if (puyoColor == 3)
            this.gameObject.GetComponent<SpriteRenderer>().color = color[Random.Range(0, 3)];

        if (puyoColor == 4)
            this.gameObject.GetComponent<SpriteRenderer>().color = color[Random.Range(0, 4)];

        if (puyoColor == 5)
            this.gameObject.GetComponent<SpriteRenderer>().color = color[Random.Range(0, 5)];

        randomColor = Random.Range(1, 6);
    }

    void Update()
    {
        if (pieceRotate == true)
            if (Input.GetKeyDown(KeyCode.X))
            {
                transform.eulerAngles += new UnityEngine.Vector3(0, 0, 0);
            }

        if (pieceFall == true)
        {
            transform.position -= new UnityEngine.Vector3(0, 0.001f, 0);
        }

        if (pieceFall == false)
        {
            transform.position -= new UnityEngine.Vector3(0, 0, 0);
        }
    }
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.layer == 2)
        {
            pieceRotate = false;
            pieceFall = false;
        }

        if (other.gameObject.layer == 3)
        {
            pieceRotate = false;
            pieceFall = false;
        }

        if (other.gameObject.layer == 4)
        {
            pieceRotate = false;
            pieceFall = false;
        }

        if (other.gameObject.layer == 5)
        {
            pieceRotate = false;
            pieceFall = false;
        }

        if (other.gameObject.layer == 6)
        {
            pieceRotate = false;
            pieceFall = false;
        }

        if (other.gameObject.layer == 7)
        {
            pieceRotate = false;
            pieceFall = false;
            this.gameObject.tag = "Other Falling 2";
        }

        if (other.gameObject.layer != 2)
        {
            pieceRotate = true;
            pieceFall = false;
            puyoScript.Fall = false;
        }

        if (other.gameObject.layer != 3)
        {
            pieceRotate = true;
            pieceFall = false;
            puyoScript.Fall = false;
        }

        if (other.gameObject.layer != 7)
        {
            pieceRotate = true;
            pieceFall = false;
            puyoScript.Fall = false;
        }

        if (this.gameObject.tag == "Falling")
        {
            pieceFall = true;
        }

        if (this.gameObject.tag == "Not Falling")
        {
            pieceFall = false;
        }

        if (this.gameObject.tag == "Other Falling")
        {
            other.gameObject.tag = "Falling";
        }

        if (this.gameObject.tag == "Other Falling 2")
        {
            other.gameObject.tag = "Other Falling";
            Debug.Log("Sucsess");
        }

        if (other.gameObject.tag == "Other Falling 2")
        {
            transform.gameObject.tag = "Other Falling";
            Debug.Log("Sucsess 3");
        }
    }
}

I’ll try one more time here and then I give up.

You have a bug. It’s time for YOU to start debugging. Here’s how:

By debugging you can find out exactly what your program is doing so you can fix it.

Use the above techniques to get the information you need in order to reason about what the problem is.

You can also use Debug.Log(...); statements to find out if any of your code is even running. Don’t assume it is.

Once you understand what the problem is, you may begin to reason about a solution to the problem.

If what you find still baffles you, come here and explain all the steps you did and why they baffle you. Here’s how:

How to report your problem productively in the Unity3D forums:

http://plbm.com/?p=220

This is the bare minimum of information to report:

  • what you want
  • what you tried
  • what you expected to happen
  • what actually happened, log output, variable values, and especially any errors you see
  • links to actual Unity3D documentation you used to cross-check your work (CRITICAL!!!)

The purpose of YOU providing links is to make our job easier, while simultaneously showing us that you actually put effort into the process. If you haven’t put effort into finding the documentation, why should we bother putting effort into replying?

I want the gameObject tag to = “Not Falling” when touching “Not Falling 2”
I don’t remember what I tried
I wanted the gameObject to = “Not Falling 2”
The Tag Didn’t change.
I don’t remember where I got my info

In the code you already posted above, tell me the line where you compare to "Not Falling 2"

  • if (this.gameObject.tag == “Other Falling 2”)
  • {
  • other.gameObject.tag = “Other Falling”;
  • Debug.Log(“Sucsess”);
  • }
    • if (other.gameObject.tag == “Other Falling 2”)
  • {
  • transform.gameObject.tag = “Other Falling”;
  • Debug.Log(“Sucsess 3”);
  • }

Do you want me to rewrite the code?

I don’t know why you think we can help you if you don’t even know basic info about your own project.

This has been going on for a long time so,

When you understand and spot the difference between these two things you have posted:

and

then you will be much closer to your solution.

Details matter. ALWAYS.

Yes, because you have been rather obstinate in refusing to listen to us. And the best thing you can do it spend some time to learn C# before continuing on with this project. A Tetris style game does require fairly decent coding knowledge, and the code we’ve seen is not going to work moving forward.

Start here: https://learn.unity.com/learn/pathway/junior-programmer

Spend some time getting your foundational skills built and work your way up to this project.

1 Like

Update: I found out the problem was that it was detecting the bottom and not the clone. How can I make OnTriggerEnter2D detect multiple game objects.