Switch for children not working

Hi there, I have a parent object with 120 childs, the code is on the parent object and I need to make a switch to do stuff based on the child’s name, and it was working just fine but I don’t know what just happened I’m not getting it to work, (the tag on the player is working and assigned)…

    private void OnTriggerStay(Collider car)
{
    if (car.tag == "Player")
    {
        Transform[] children = GetComponentsInChildren<Transform>();
        foreach (Transform child in children)            
            {                
            switch (child.name) //<-Also used this.name and was working fine
            {
                case "0":
                    player.transform.localPosition = new Vector2(-17, 9);
                    break;

                case "1":
                    player.transform.localPosition = new Vector2(-16, 4);
                    break;

                case "2":
                    player.transform.localPosition = dos;
                    break;
            }
            }…

Not getting an error it’s just not doing anything :frowning: help please

Does your Car has a RigidBody attached to it and a collider set to “isTrigger” ?

BTW: Are you sure you want to do that? Right now you doing 120 checks on every physic update …

Use Debug.Log to check if the collision and the tag is working fine. If not, you know where your problem is :slight_smile: