Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class SpawnerScript : MonoBehaviour {
- public Transform prefab;
- // Use this for initialization
- void Start () {
- }
- // Update is called once per frame
- //depending on the level of game(?) the chance to spawn an object will increase
- //for now, if random number is 10 or smaller
- void Update () {
- if(Random.Range(0, 100) <= 10){
- Instantiate(prefab, GetSpawnPoint(), Quaternion.identity);
- }
- }
- //calculate random spawn point from the circle and return it
- Vector3 GetSpawnPoint(){
- Vector3 spawnPoint;
- int radius = 5;
- float angle = Random.Range(0, 8) * Mathf.PI * 2;
- spawnPoint = new Vector3(Mathf.Cos(angle), Mathf.Sin(angle)) * radius;
- return spawnPoint;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement