Скрипт генерации карты

Почти готовый скрипт генерации карты - готова генерация при запуске сцены, создаётся заданное число тайлов. Начал писать удаление и создание новых тайлов по тому, пока идёт игрок.
This commit is contained in:
LikhenkoVG
2024-12-10 20:01:30 +03:00
parent f3552bb159
commit 3d15c0dc4c
5 changed files with 126 additions and 56 deletions

View File

@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.UIElements;
public class SpawnTileScript : MonoBehaviour
{
@ -17,19 +18,20 @@ public class SpawnTileScript : MonoBehaviour
}
private void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag == "Player")
{
if (_Instantiated)
{
GenerateTile(_Tiles[0]);
}
}
}
//private void OnTriggerEnter(Collider other)
//{
// if (other.gameObject.tag == "Player")
// {
// if (_Instantiated)
// {
// GenerateTile(_Tiles[0]);
// }
// }
//}
private void GenerateTile(GameObject tile)
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, new Vector3(_CurrentTile.transform.position.x, _CurrentTile.transform.position.y, _CurrentTile.transform.position.z+20), _CurrentTile.transform.rotation);
Instantiate(tile, pos, rot);
}
}