I have a script that will generate random characters but I want all of the generated objects have the same AI but may be with different behaviors. For so I have the AI as a prefab (everything configured) so I do:
GameObject ai = (GameObject)Instantiate (AIPrefab);
aiRig = (AIRig) ai.GetComponent<AIRig> ();
ai.transform.parent = transform;
But the line that makes the game crash is this one:
aiRig.AI.Body = newGO; // newGO is the gameobject generated
And without assign the AI.Body the behaviors are not implemented onto the object… How can I achieve this?