How to add an attribute to a spawned object

Hello,

I made a script that spawns a prefab named ‘unit’ each time I press ‘E’. The thing is that I must link a path attribute to this newly spawned unit in order for the unit to start moving. (think at it like at a tower defense creep wave, where it spawns and starts to move along a pre-defined path)

What to add to the spawn script ?

Note 1: A spawned unit must contain the following object in order for it to move:

  • WaypointManager (a script) - DONE ;

  • pathContainer (a path determined by waypoints created with WaypointManager) - needs to be done

Ok.

So what you have to do is load each path as an arraylist, and pull each value incrementally.
import System.Collections.Generic

public List<Transform> PathPoints;

//and later

foreach(Transform i in PathPoints){

//Use i as you next waypoint


}