Почти готовый скрипт генерации карты - готова генерация при запуске сцены, создаётся заданное число тайлов. Начал писать удаление и создание новых тайлов по тому, пока идёт игрок.
38 lines
982 B
C#
38 lines
982 B
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.CompilerServices;
|
|
using UnityEngine;
|
|
using UnityEngine.UIElements;
|
|
|
|
public class SpawnTileScript : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private List<GameObject> _Tiles = new List<GameObject>();
|
|
[SerializeField]
|
|
private GameObject _CurrentTile;
|
|
|
|
private bool _Instantiated = false;
|
|
|
|
private void Start()
|
|
{
|
|
|
|
}
|
|
|
|
//private void OnTriggerEnter(Collider other)
|
|
//{
|
|
// if (other.gameObject.tag == "Player")
|
|
// {
|
|
// if (_Instantiated)
|
|
// {
|
|
// GenerateTile(_Tiles[0]);
|
|
// }
|
|
// }
|
|
//}
|
|
|
|
public void GenerateTile(GameObject tile, Vector3 pos, Quaternion rot)
|
|
{
|
|
//Instantiate(tile, new Vector3(_CurrentTile.transform.position.x, _CurrentTile.transform.position.y, _CurrentTile.transform.position.z+20), _CurrentTile.transform.rotation);
|
|
Instantiate(tile, pos, rot);
|
|
}
|
|
}
|