- Home /
Take array and waypoints from parent spawnner
Hello,
I have an AI that patrols between a series of waypoints, however when I spawn the AI from a spawnner they don't hold the waypoints in the array.
I was told I should hold the array of waypoints in the spawner and that when the AI is spawned it takes the waypoints and fills the array it carries. Any idea how I go about doing this?
Please provide some code so we know which stage you're at
Answer by toddisarockstar · May 03, 2017 at 05:39 AM
assuming the same waypoints are used by all AI.
instead of holding the waypoints in each AI, I would hold the waypoints in a single masterscript somewhere and Simply marks the arrays as public static so they are accessible to everyone when needed.
cheezy example to get scripts talking:
put this in the master script and attach to the camera or something that isnt going anywhere:
public static string funny;
void Start() {
funny = "turtle";}
now put this in your AI script:
if(Input.GetKey("space")){
print (nameofmasterscript.funny);}
//prints turtle for each AI!!!!
Your answer
Follow this Question
Related Questions
GetComponent searches an objects child instead of the object 2 Answers
Making a GetComponent array 1 Answer
Is there any way to use parenting as an organization tool without creating a Transform bond? 3 Answers
Destroy(other.gameObject) isn't destroying parent, only children 2 Answers
Make a simple tree 1 Answer