Hi folks,I have a little problems that’s drive me in crazy. When I instantiate dinamically some gameObjects, I add to it a route and I want specify that route on a script named getRota. But I isn’t happening. When I test my application, they haven’t a route (getRoute.route=null). Someone can help me with this?
getRoute.cs:
public class getRoute : MonoBehaviour {
public MonoBehaviour route;
}
instantiateNPCwandering.cs:
void Start () {
GameObject gmO=this.gameObject;
while(loop)
{
if(toClone!=null)
gmO=Instantiate(toClone,transform.position+OnUnitCircle()*2,Quaternion.identity) as GameObject;
gmO.AddComponent ("wanderCircle");
if(!gmO.GetComponent<getRoute>())
gmO.AddComponent ("getRoute");
gmO.GetComponent<getRoute>().route=(MonoBehaviour)gmO.GetComponent<wanderCircle>();
howMany++;
if(howMany==total)
loop=false;
}
}