// Update is called once per frame void Update() { if (Enemy == null) { Enemy = Instantiate(enemyPrefab) as GameObject; Enemy.transform.position = new Vector3(0, 1, 0); float angle = Random.Range(0, 360); Enemy.transform.Rotate(0, angle, 0); wanderingAI = Enemy.GetComponent <WanderingAI>(); wanderingAI.OnSpeedChanged(speedMultiplier); } }