So each of the parent of the cube has an instance of Waypoint.cs. And the Enemy empty has the EnemyMover.cs, to wich we pass instances of the cube’s parent, all of them gameObjets.
This code does work, but i dont unsderstand the Waypoint reference
using System.Collections.Generic;
using UnityEngine;
public class EnemyMover : MonoBehaviour
{
[SerializeField] List<Waypoint> path = new List<Waypoint>();
void Start()
{
PrintWayPointName();
}
void PrintWayPointName() {
foreach(Waypoint waypoint in path) {
Debug.Log("waypoint: " + waypoint.name);
}
}
}
So in
[SerializeField] List<Waypoint> path = new List<Waypoint>();
// how come those objects passed to [SerializeField] are Waypoint instances, and not GameObjects?
// shoudn't this be
[SerializeField] List<GameObject> path = new List<GameObject>();
thanks