2021-10-31 13:43:04 -06:00
|
|
|
|
using UnityEngine;
|
2021-09-24 00:34:18 -06:00
|
|
|
|
|
|
|
|
|
public class PlatformManager : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
// Array setup for platforms
|
|
|
|
|
GameObject[] platforms;
|
|
|
|
|
GameObject currentPlatform;
|
|
|
|
|
int index;
|
|
|
|
|
|
|
|
|
|
// GameObject for coin appearing above platform
|
|
|
|
|
public GameObject coin;
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
{
|
|
|
|
|
NewPlatform();
|
|
|
|
|
}
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
public void NewPlatform()
|
|
|
|
|
{
|
|
|
|
|
platforms = GameObject.FindGameObjectsWithTag("Platform"); // Creates an array of all objects with the tag platform
|
|
|
|
|
index = Random.Range(0, platforms.Length); // randomly selects one platform
|
|
|
|
|
currentPlatform = platforms[index]; // registers random platform as the one the player must get to
|
|
|
|
|
coin.transform.position = new Vector2(currentPlatform.transform.position.x, currentPlatform.transform.position.y + 2f);
|
|
|
|
|
}
|
|
|
|
|
}
|