36 lines
811 B
C#
36 lines
811 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public class HeroSpawner : MonoBehaviour
|
|
{
|
|
public GameObject hero;
|
|
public float timeRemaining = 3;
|
|
private float originalTimeRemaining;
|
|
private float[] yPositions = new float[]{4.0f, 2.0f, 0.0f, -2.0f, -4.0f};
|
|
|
|
void Start()
|
|
{
|
|
originalTimeRemaining = timeRemaining;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
if (timeRemaining > 0)
|
|
{
|
|
timeRemaining -= Time.deltaTime;
|
|
} else
|
|
{
|
|
SpawnHero();
|
|
}
|
|
}
|
|
|
|
void SpawnHero()
|
|
{
|
|
float heroStartingX = -3.0f;
|
|
float heroStartingY = 0.0f;
|
|
Vector2 heroStartingPosition = new Vector2(heroStartingX, heroStartingY);
|
|
timeRemaining = originalTimeRemaining;
|
|
GameObject spawnedHero = Instantiate(hero, heroStartingPosition, Quaternion.identity);
|
|
}
|
|
}
|