Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class MobSpawnerScript : MonoBehaviour
- {
- [SerializeField]
- public GameObject wolf;
- [SerializeField]
- public GameObject bunny;
- [SerializeField]
- public int wolfAmount;
- [SerializeField]
- public int bunnyAmount;
- [SerializeField]
- public float wolfLifespan;
- [SerializeField]
- public float wolfRandomSpeedMin;
- [SerializeField]
- public float wolfRandomSpeedMax;
- public float xPosition;
- public float zPosition;
- //private float yPosition;
- private void Start()
- {
- SpawnAnimal("wolf");
- //WolfLifespan();
- }
- void SpawnAnimal(string species)
- {
- if(species == "bunny")
- {
- SpawnBunny();
- } else if (species == "wolf"){
- SpawnWolf();
- }
- }
- void SpawnWolf()
- {
- while (wolfAmount > 0)
- {
- Debug.Log("Creating" + wolfAmount + "wolf");
- xPosition = Random.Range(-10f, 10f);
- zPosition = Random.Range(-10f, 10f);
- //yPosition = Random.Range(5f, 7f);
- Instantiate(wolf, new Vector3(xPosition, 0f, zPosition), Quaternion.Euler(0.0f, Random.Range(0.0f, 360.0f), 0.0f));
- wolfAmount--;
- }
- }
- void SpawnBunny()
- {
- while (bunnyAmount > 0)
- {
- Debug.Log("Creating" + bunnyAmount + "bunny");
- xPosition = Random.Range(-10f, 10f);
- zPosition = Random.Range(-10f, 10f);
- //yPosition = Random.Range(5f, 7f);
- Instantiate(bunny, new Vector3(xPosition, 0f, zPosition), Quaternion.Euler(0.0f, Random.Range(0.0f, 360.0f), 0.0f));
- bunnyAmount--;
- }
- }
- public void NewWolf(Vector3 newPosition)
- {
- GameObject newWolf = Instantiate(wolf, transform.position, transform.rotation);
- newWolf.transform.position = newPosition;
- newWolf.transform.rotation = Quaternion.Euler(0, Random.Range(0, 360), 0);
- }
- /*void WolfLifespan()
- {
- WolfController wolfController = GameObject.Find("Wolf").GetComponent<WolfController>();
- wolfController.wolfLifespanDuration = wolfLifespan;
- wolfController.randomSpeedMin = wolfRandomSpeedMin;
- wolfController.randomSpeedMax = wolfRandomSpeedMax;
- }*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement