In the video, we create a variable inside of a method:
var waveWaypoints = new List< Transform >();
I know we’ve done something similar with Vector2, but I’ve never really understand why we need to use “new”. Could someone explain what is going on here?
Why doesn’t “List< Transform > waveWaypoints” work instead?
Full method:
public List<Transform> GetWaypoints()
{
var waveWaypoints = new List<Transform>();
foreach (Transform child in pathPrefab.transform)
{
waveWaypoints.Add(child);
}
return waveWaypoints;
}
Thank you!