Is there a solution for the waypoint prefab issue?

I have a prefab of an enemy AI car, and a script which will instantiate this prefab at set intervals.
I want to have the instantiated prefab follow a waypoint course, to strafe our base.
The problem is that when I make a prefab out of the enemy car, it loses the waypoint circuit assigned to it.
I tried re-assigning the waypoint circuit to the prefab, but Unity won’t let me do that.
I tried making a prefab out of the waypoint circuit. Unity will allow me to assign that prefab (of the waypoint circuit) to the prefab of the enemy car, but when instantiate that prefab I get the error message:

“IndexOutOfRangeException: Array index is out of range.
UnityStandardAssets.Utility.WaypointCircuit.GetRoutePosition (Single dist) (at Assets/Standard Assets/Utility/WaypointCircuit.cs:66)”

I’m hoping that there is a way to use code to assign the original waypoint circuit to the circuit variable of the WaypointProgressTracker.cs (the script attached to the car, where you drag & drop the desired waypoint circuit.)

The real problem is that I am not (yet) much of a coder - still working my way through the beginner set of tutorials… I’m just unsure what my approach to this problem should be - I tried making an alternate version of the WaypointProgressTracker.cs script, to allow me to assign the waypoint circuit on Start, but that effort failed every which way, again, because at this point, I’m still in waaay over my head. :slight_smile:

If anybody can share a working solution for this issue, I would be most grateful.
At this point, the work-around is pretty ugly - have a bazillion copies of the enemy car in scene, but set inactive, and a script to activate them… works, but I’d really prefer to have the cleaner approach of instantiating a prefab.

Thanks for any help!

Well, I have step one and (sort of) two - I can instantiate my car, and I can make a variable for a public Behaviour, and assign the WaypointProgressTracker script to it in the inspector…
What I can’t find a way to do is the last step - assigning the desired waypoint circuit.
As I mentioned, I tried making an alternate version of the WaypointProgressTracker.cs script, to allow me to assign the waypoint circuit, but because I really don’t know my way around coding yet, I can’t figure out exactly how to do that last step…

Any ideas?

Hello ! I was having the same problem and I figured out what was going on.
There is 2 Waypoint Circuit scripts.
You need to use the one that do not propose to change the color and you need to drag the script into the inspector. Not the gameObject.