2025-03-15 14:47:42 +01:00
|
|
|
using UnityEngine;
|
|
|
|
/// <summary>
|
|
|
|
/// Platform generator logic
|
|
|
|
/// Original Guide on YouTube link: https://www.youtube.com/watch?v=NtY_R0g8L8E.
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
public class PlatformGenerator : MonoBehaviour
|
|
|
|
{
|
2025-03-17 20:17:49 +01:00
|
|
|
/*
|
2025-03-15 14:47:42 +01:00
|
|
|
[SerializeField] private Transform platformStart;
|
|
|
|
[SerializeField] private System.Collections.Generic.List<Transform> platformList;
|
|
|
|
[SerializeField] Vector2 nextSpawnPos;
|
|
|
|
|
|
|
|
private Vector2 lastEndPosition;
|
|
|
|
|
|
|
|
private void Awake()
|
|
|
|
{
|
|
|
|
Vector2 positionPlat = platformStart.Find("Endposition").position;
|
|
|
|
lastEndPosition = positionPlat;
|
|
|
|
|
|
|
|
int startingSpawnLevelPlat = 5;
|
|
|
|
for (int i = 0; i < startingSpawnLevelPlat; i++)
|
|
|
|
{
|
|
|
|
SpawnLevelPlat();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void SpawnLevelPlat()
|
|
|
|
{
|
|
|
|
// Platform is choosed different
|
|
|
|
Transform currentPlat = platformList[Random.Range(0, platformList.Count)];
|
|
|
|
// Platform spawns
|
|
|
|
Transform lastLevelPlatTransform = SpawnLevelPlat(currentPlat, lastEndPosition);
|
|
|
|
lastEndPosition = lastLevelPlatTransform.Find("EndPosition").position;
|
|
|
|
}
|
|
|
|
|
|
|
|
private Transform SpawnLevelPlat(Transform levelPlat, Vector2 spawnPosition)
|
|
|
|
{
|
|
|
|
Transform platformLevelTransform = Instantiate(levelPlat, spawnPosition, Quaternion.identity);
|
|
|
|
return platformLevelTransform;
|
2025-03-17 20:17:49 +01:00
|
|
|
}*/
|
2025-03-15 14:47:42 +01:00
|
|
|
}
|