24 lines
684 B
C#
24 lines
684 B
C#
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using UnityEngine;
|
||
|
|
||
|
/// <summary>
|
||
|
/// Platform spawner
|
||
|
/// Original script found in: https://stackoverflow.com/questions/75924903/instantiating-and-destroying-unity-prefabs.
|
||
|
/// </summary>
|
||
|
|
||
|
public class PlatformSpawner : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private int platformCount;
|
||
|
[SerializeField] private OffScreenDestroyPlatform platformPrefab;
|
||
|
|
||
|
void Start()
|
||
|
{
|
||
|
for (int i = 0; i < platformCount; i++)
|
||
|
{
|
||
|
var spawnPosition = new Vector2(Random.Range(1f, 10f), Random.Range(-2f, 2f));
|
||
|
Instantiate(platformPrefab, spawnPosition, Quaternion.identity);
|
||
|
}
|
||
|
}
|
||
|
}
|