Grabbing GameObjects and putting into Transform array?

Hi there!

So, I was wondering on how to make something grab GameObjects and putting them into a array.

I’ve tried this

public Transform[] Waypoints = GameObject.FindGameObjectsWithTag("Waypoint");

But It doesn’t work.

If anyone could help me that would be great!
Thank you!

FindGameObject returns an array of gameObject, not their transforms.,
See Unity - Scripting API: GameObject.FindGameObjectsWithTag

Your error message should have made this clear, always look at your compiler messages first, and the online docs next.

What you need to do is loop on them and get their transforms.

eg

public GameObject[] WaypointObjects = GameObject.FindGameObjectsWithTag("Waypoint");
public Transform[] WaypointTransforms = new Transform[WaypointObjects.Length];
for(int i=0;i<WaypointObjects.Length;i++){
  WaypointTransforms _= WaypointObjects*.transform;*_

}