Unity If & else statement

So i've 5 different objects and every time i click on a specific object the should be place in order. but instead of them being put in order it seems to skip the first to the second. So instead of going to check1 it goes straight to check2

this is my code

if (IsBehindHeld == true)
    {
        Vector3 MousePos;
        MousePos = Input.mousePosition;
        MousePos = Camera.main.ScreenToWorldPoint(MousePos);


        if (Check1.transform.childCount != 1)
        {
            this.gameObject.transform.position = Check1.transform.position;
            _rb2.isKinematic = true;
            locked = true;

            this.transform.parent = Check1.transform;

        }

        else
        {
            if (Check2.transform.childCount != 1 )
            {
                this.gameObject.transform.position = Check2.transform.position;
                _rb2.isKinematic = true;
                locked = true;

                this.transform.parent = Check2.transform;

            }

            else
            {
                if (Check3.transform.childCount != 1)
                {
                    this.gameObject.transform.position = Check3.transform.position;
                    _rb2.isKinematic = true;
                    locked = true;

                    this.transform.parent = Check3.transform;

                }

                else
                {

                }
            }
        }

    }


Read more here: https://stackoverflow.com/questions/64407907/unity-if-else-statement

Content Attribution

This content was originally published by Valon Cazimi at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: