Thank you very much, I couldn't find a video about using rule tiles in world generation. Thank you!👏
@larsmaasanimaties45942 жыл бұрын
i made this but instead of placing tiles. i just changed pixels on a texture. Works great. thank you
@apesign86682 жыл бұрын
Great video. It's simple to follow and works just fine
@liam99963 жыл бұрын
TerrenGeneration!
@liam99963 жыл бұрын
@MioShimura The method name...
@v0id_d3m0n2 жыл бұрын
thank you! this was really helpful
@MrCrompz3 жыл бұрын
1:26 i dont have the new components from the script
@FLStudioTutorialz3 жыл бұрын
Great explanation. Thank you very much for your effort. It helps a lot.
@eduato_yt2 жыл бұрын
great video dude!
@Tyquanfanboy3 жыл бұрын
i cant use the tile map you posted in the description
@Austeja6082 жыл бұрын
for some reason for me it only generates square same as in 9:21 entire code: using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Tilemaps; using Unity.VisualScripting; public class generation : MonoBehaviour { [SerializeField] int width, height; [SerializeField] float smoothness; [SerializeField] float seed; [SerializeField] TileBase groundTile; [SerializeField] Tilemap groundTilemap; int[,] map; // Start is called before the first frame update void Start() { Generation(); } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Generation(); } } void Generation() { groundTilemap.ClearAllTiles(); map = GenerateArray(width, height, false); map = terraingeneration(map); RenderMap(map, groundTilemap, groundTile); } public int[,] GenerateArray(int width, int height, bool empty) { int[,] map = new int[width, height]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { map[x, y] = (empty) ? 0 : 1; } } return map; } public int[,] terraingeneration(int [,] map) { int perlinHeight; for (int x = 0; x < width; x++) { perlinHeight = Mathf.RoundToInt(Mathf.PerlinNoise(x / smoothness, seed) * height); for (int y = 0; y < perlinHeight; y++) { map[x, y] = 1; } } return map; } public void RenderMap(int[,] map , Tilemap groundTilemap, TileBase groundtilebase ) { for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (map[x,y] == 1) { groundTilemap.SetTile(new Vector3Int(x, y, 0), groundtilebase); } } } } }
@solomonr47282 жыл бұрын
same
@xxxxxxxxxxxxxxxxxx122 жыл бұрын
i have solution that worked, change this false to true "map = GenerateArray(width, height, false);".
@jaymhlurbaloyi78133 жыл бұрын
can you do a 2D top-down version of this
@jkewlo4 жыл бұрын
Anyone having problems with the camera? and the bottom left meeting at the center of the camera?
@chronoabi3 жыл бұрын
Yeah its because the position (0,0,0) is the center of the video
@mysterymatt47613 жыл бұрын
@@chronoabi a little more explanation on this question please! :D ur rly one oft he greatest tutorial makers out here!
@danielreparos70502 ай бұрын
Can you do this with tile?
@jiakai7254 Жыл бұрын
hi I cannot drag and drop things from hierarchy/assets to inspector pls help TT (Mac user)
@suprememarshal20152 жыл бұрын
Nice tutorial. How can I check for specific tile being next to the rule tile? I need to check if a tile is stone then use a stone variant and if it's next to dirt, it use dirt variant. But if I make two separate rule tiles, they won't work together when a dirt rule tile is next to a stone rule tile.
@pixelpat7773 жыл бұрын
Great video thanks @ChronoABI !!! What if i wanted to add perlin noise octaves to this, where and what would i put?
@justadudewhoplaysgames2262 Жыл бұрын
can someone help? its only generating a square instead of procedural square
@search_me_tilak4 жыл бұрын
Superb plz upload more videos
@chronoabi4 жыл бұрын
Sure 😊
@BigGuy072 жыл бұрын
How many people noticed that he typed in 69 and 420 in as the seed? Nice.
@Lubicabis3 жыл бұрын
How can i put a Collider on the tiles, i use a rule tile, with the collide type "Sprite" but nothing happens if my player falls on it so he falls through it edit: solved it myself, just put a tilemap collider on the tilemap!
@Rpars202 жыл бұрын
use the "TileMap Collider2D" on your groundTileMap
@JasonEllingsworth2 жыл бұрын
I am going nuts here, and since I am pretty sure I got the code from you or from the blog, maybe you can help. I need to have all the tiles have their own identity, or be their own instanced unique object. I use playmaker because I am very new. I need to basically attach an FSM either beforehand or on collision that destroys the tile if it is collided with a projectile. How do I achieve this? Currently in the hierarchy only one object is made that is the entire terrain with one Tilemap Collider. Any help you could give would be great and thank you.
@chronoabi Жыл бұрын
Use game objects like prefabs of your individual tile so that all of them are seperate. Sorry for the late reply
@sripranav3 жыл бұрын
Can we make it much more smoother?
@elithevil4 жыл бұрын
great vid, tnx! i have one issue tho, for some reason pressing space doesnt do anything not does it show any errors..not sure why. ive also added debug log both before and after clearAllTiles and its shows both when i press space. code: [SerializeField] int width, height; [SerializeField] float smoothness; [SerializeField] float seed; [SerializeField] TileBase groundTile1; [SerializeField] Tilemap groundTilemap; int[,] map; // Start is called before the first frame update void Start() { seed = Random.Range(0, 100000); Generation(); } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Generation(); } } void Generation() { groundTilemap.ClearAllTiles(); map = GenerateArray(width, height, true); map = TerrainGeneration(map); RenderMap(map, groundTilemap, groundTile1); }
@chronoabi4 жыл бұрын
Give me like your whole code bro I will test it out. Edit : I tried it and it works perfectly so give me your code
@elithevil4 жыл бұрын
@@chronoabi using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.Tilemaps; public class ProcGeneration : MonoBehaviour { [SerializeField] int width, height; [SerializeField] float smoothness; [SerializeField] float seed; [SerializeField] TileBase groundTile1; [SerializeField] Tilemap groundTilemap; int[,] map; // Start is called before the first frame update void Start() { seed = Random.Range(0, 100000); Generation(); } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Q)) { Generation(); } } void Generation() { groundTilemap.ClearAllTiles(); map = GenerateArray(width, height, true); map = TerrainGeneration(map); RenderMap(map, groundTilemap, groundTile1); } public int[,] GenerateArray(int width, int height, bool empty) { int[,] map = new int[width, height]; for (int x = 0; x < width; x++) { for (int y = +0; y < height; y++) { if (empty) { map[x, y] = 0; } else { map[x, y] = 1; } } } return map; } public int[,] TerrainGeneration(int[,] map) { int perlinHeight; for (int x = 0; x < width; x++) { perlinHeight = Mathf.RoundToInt(Mathf.PerlinNoise(x / smoothness, seed) * height); for(int y = 0; y < perlinHeight; y++) { map[x, y] = 1; } } return map; } public void RenderMap(int[,] map, Tilemap groundTileMap, TileBase groundTilebase) { for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (map[x,y] == 1) { groundTilemap.SetTile(new Vector3Int(x, y, 0), groundTilebase); } } } } }
@chronoabi4 жыл бұрын
BRUH void Update() { if (Input.GetKeyDown(KeyCode.Q)) { Generation(); } } Did you try pressing Q 😂😂🤣
@elithevil4 жыл бұрын
@@chronoabi yea ive just changed it for my preference but its the same thing. if i remove generation(); from start function, than i press q, it generates a world. but if its already generated nothing happens.. from what i understand it should remove all tiles than just make new ones.
@chronoabi4 жыл бұрын
That is because you have to put different seed value everytime before generating tile. Try putting "Seed = Random.Range(0,100000)" in the generation function just after your clearAllTiles
@Ahmed-ic9ft4 жыл бұрын
could u do a chunk feature so that only visible chunk is active so that to map can be bigger without lag
@chronoabi4 жыл бұрын
I am trying learn /figure that out. So once I do that I will
@Ahmed-ic9ft4 жыл бұрын
@@chronoabi this might help: github.com/Xonor13/Tranquility
@Ahmed-ic9ft4 жыл бұрын
also a vid: kzbin.info/www/bejne/mqGog2mvmdR2mac
@chronoabi4 жыл бұрын
@@Ahmed-ic9ft thankyou soo much bro. I was trying to figure out how to move through procedurally generated world for so long. Love you bro🤩
@zanspl4 жыл бұрын
@@chronoabi This would be amazing to implement into this project :O
@zanspl4 жыл бұрын
Hey so for some reason nothing gets spawned in, but there are no errors shown, could it be that i have my rule tile wrongly made?
@chronoabi4 жыл бұрын
Show me the code bro.
@zanspl4 жыл бұрын
@@chronoabi public class ProceduralGeneration : MonoBehaviour { [SerializeField] int width, height; [SerializeField] TileBase groundTile; [SerializeField] Tilemap groundTilemap; int[,] map; void start() { map = GenerateArray(width, height, false); RenderMap(map, groundTilemap, groundTile); } public int [,] GenerateArray(int width, int height, bool empty) { int[,] map = new int [width, height]; for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { map [x, y] = (empty) ? 0: 1; } } return map; } public void RenderMap(int[,] map, Tilemap groundTileMap,TileBase groundTilebase) { for (int x = 0; x < width; x++) { for (int y = 0; y < height; y++) { if (map[x,y] == 1) { groundTileMap.SetTile(new Vector3Int(x, y, 0), groundTilebase); } } } } }
@elithevil4 жыл бұрын
@@zanspl i think it should be true, not false in: void start() { map = GenerateArray(width, height, false); RenderMap(map, groundTilemap, groundTile); }
@zanspl4 жыл бұрын
@@elithevil Nope same with true, also first he tries it with false (9:16), and then shows us how when its true(9:45) it doesnt spawn anything :/
@chronoabi4 жыл бұрын
Bro your start Has a small "s" that's why ist not registering as the start function of the game. For a minute even I was "Wait like nothing is wrong here why is it not working" 😂😂
@lozD832 жыл бұрын
"Discription"
@The_Dxvil2 жыл бұрын
so i like this but use the next time other scripts that u dont need to use tilemaps and i used instead of tilemaps Sprite2d and it doesn't create bugs anymore because i was doing soething like that a long time ago and had so many bugs with it and now im making a 2d game with a terrain generator and it doesn't have bugs anymore because i changed so much with the terrain generator and added 2 scripts and it works fine even if i stress test it like i want 1000 generated and it makes it really fine and really fast
@chronoabi Жыл бұрын
Sorry for the late reply. But thankyou soo much for the suggestion . I will try to implement this in my project and continue this series shortly
@gsc89025 ай бұрын
69 420 hahaha "legendary values"
@КсенийКот2 ай бұрын
This is very inefficient. You may rethink the code completely if you are making an implementation in a production project
@MysticpyMC2 жыл бұрын
[SerializeField] int width, height; [SerializeField] float smoothness; [SerializeField] float seed; [SerializeField] TileBase groundTile1; [SerializeField] Tilemap groundTilemap; int[,] map; // Start is called before the first frame update void Start() { seed = Random.Range(0, 100000); Generation(); } // Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space)) { Generation(); } } void Generation() { groundTilemap.ClearAllTiles(); map = GenerateArray(width, height, true); map = TerrainGeneration(map); RenderMap(map, groundTilemap, groundTile1); }
@chronoabi Жыл бұрын
what is this bro ??
@chronoabi Жыл бұрын
Wait is that an Improved version of my code?? Bro thats quite cool 🤯