/**************************************************************************************************/ //spawn another seed above player private void SpawnSeed() { Quaternion rot = Quaternion.Euler(0, 0, transform.eulerAngles.z - 180); //rotate it down EntSeed temp = Instantiate(this.gameObject, playerPosition, rot).GetComponent <EntSeed>(); //spawn seed temp.SetDuration(5, pPos); //set the duration and transform }
/**************************************************************************************************/ //shoot 5 seeds stright up public IEnumerator SpawnSeed() { for (int i = 0; i < 5; i++) { float ran = Random.Range(0, direction.x * 5); //random number between 0 and 5 or -5 and 0, based on direction Quaternion rot = Quaternion.Euler(0, 0, ran); //rotation from up by the random number Vector3 playerPos = playerPosition.position + new Vector3(ran - (direction.x * 2), 15, 0); //position second seed spawns from above player //shifted horizontaly by the random number EntSeed temp = Instantiate(seed, transform.position, rot).GetComponent <EntSeed>(); //instantiate the seed temp.SetDown(2, playerPos, playerPosition, true); //set the duration second spawn location, player transform, and spawn another yield return(new WaitForSeconds(.2f)); //wait to fire again } StopCoroutine(SpawnSeed()); //stop coroutine }