GetComponents won't assign

Hello, I am currently have some problems with my code. I am trying to set the value of an array but I keep getting an error stating that GameComponent does not have a definition for GetComponents

public Collider2D[] platCol;
public GameObject[] platforms;


void Awake()
    {

        platforms = GameObject.FindGameObjectsWithTag("Solid");
        platCol = platforms.GetComponents<Collider2D>();

    }

You’re attempting to call GetComponents on an array of GameObjects. If you want to get all the Collider2D components on all the GameObjects in the platforms variable, you will need to iterate the array and call GetComponents on each one.

1 Like