Thanks! Working on a project that generates a world using Perlin Noise and I wanted to add some extra information to each tile regarding the town that occupies that space. Very useful!
@FlipYourLearning2 жыл бұрын
This was amazingly useful. I had been trying to implement a similar system for days and honestly wasn't expecting to find a video showing how to do such a niche thing (I want to use it for immune cells and bacteria leaving trails of molecules as they move. My best bet at first was to look for temperature maps and heat transfer simulation videos, but it didn't work well. Suddenly I saw your miniature mentioning stink, and I realized that it was exactly what I needed, and the video did not disappoint). Thanks a lot.
@bm34102 жыл бұрын
"adjust it for the x and y, and add some stink" *thumbs up*
@titushenson82272 жыл бұрын
Took my like an hour to find this just what I was looking for
@gavin_is_gavin62922 жыл бұрын
oh man, thanks for the info about the color lock. I had no idea why my code wasn't working!
@pavelholub62752 жыл бұрын
Thanks for this! Now i am able to make humidity, organic matter and heat maps :)
@manyfailsonewin43522 жыл бұрын
This and the other video about tiles has been extremely helpful. I shot myself in the foot by accidentally making the darker stink tile on alpha 0 and kept wondering why my second and third clicks were making things fade lol. This will help me immensely in creating a tiled game with water and other flowing types of materials (I hope!). So far so good!
@ShackMan2 жыл бұрын
That happens to everyone, Unity sets the alpha of new colors to 0. Must have wasted about a million hours of dev time in total...cool user name btw, great attitude :-)
@manyfailsonewin43522 жыл бұрын
@@ShackMan ahh that makes me feel a little better. i was wondering how i managed to goof that up. thanks!
@krissichan31274 жыл бұрын
Beautiful my man, very good.
@322ss3 жыл бұрын
Pretty nice stuff! I've done something similar, but I've never considered using updating tiles in runtime scenarios. Have you done any profiling/testing, how many updating tiles will bog your computer down?
@ShackMan3 жыл бұрын
I didn't do actual profiling, just stress testing and it could handle a lot! I've found tilemaps to be quite performant in general, and my method here doesn't do that much work. And it could of course be optimized when you know what exactly your game needs.
@obygdengaming4 жыл бұрын
Thanks for the tutorials! Quick question, how would I go about iterating through all the tiles in the tilemap, finding all tiles with a certain Int value set in their TileData, and add them to a list? I am new to Tilemaps and Scriptable objects, and get a bit confused with all the new terms lol
@ShackMan4 жыл бұрын
Use Tilemap.origin to get the lower left corner and Tilemap.origin + Tilemap.size for the top right corner. Those are vectors giving you the positions. That way you can loop through all the tiles. Checking whether a tile has a certain stink value is then a simple if statement. In this video I only added the stinking tiles to the dictionary. So you could loop through all positions in the tilemap and check if the stinkingTiles dictionary has that position as a key, if so, get the value of that key to check the stink value.
@obygdengaming4 жыл бұрын
@@ShackMan Ahhh I figured it out! Thanks so much! I'm gonna post my solution here if anybody else needs it: //Get the map area BoundsInt bounds = map.cellBounds; // Get all tiles in map area TileBase[] allTiles = map.GetTilesBlock(bounds); //Iterate through all tiles foreach(TileBase tile in allTiles){ //Make sure there is a tile at position and check a bool from the TileData if(tile != null){ if(dataFromTiles[tile].switchTile == true){ Debug.Log("Found Switchable Block"); // adds it to a list based on a TileData int value if(dataFromTiles[tile].switchNumber == 0){ switchableTiles0.Add((dataFromTiles[tile])); } } } }
@AlexFSTR2 жыл бұрын
Hello, I have a tile animation, but I would like to place it in a tilemap, I would like to do all this in code. But tilemap has only one function which is SetTile() which asks me for a TileBase, so the question, how can I convert my TileAnimatorData to TileBase?
@ShackMan2 жыл бұрын
You could write a script that just swaps the sprite every 0.x seconds with SetTile, looping through a list of your sprites. Sounds incredibly bad for performance, but I think it's always worth trying it out and see what happens. There are of course animated tiles that you can create in the inspector, but I've never tried out how to set the sprites through script. docs.unity3d.com/Packages/com.unity.2d.tilemap.extras@1.6/manual/AnimatedTile.html
@TengizAdamashvili2 жыл бұрын
Question. How would you store unique data in EVERY tile? I can iterate over each tile and that gives me row and col values, which do not correspond to grid_position values. I tried getting a world bounding box position, so I can find each tile by iterating coordinates but the tilemap bounding box is super janky and simply wrong and unreliable. Please advice
@ShackMan2 жыл бұрын
Not sure, what what you mean... the row and col value should exactly correspond to a grid position, by which you can get the world position (the center of the tile).
@HazebertM3 жыл бұрын
Hi, great tutorial! I've been following along but, every time I run the first test, it never adds color. When I turn the alpha back up, clicking the just removes the tile. I've followed the code completely as shown in the video. Any idea of what I might be doing wrong? Thanks!
@ausername4meplease Жыл бұрын
Can this system be used in a farming game where you dig, water and plant things in tiles? What about performance? Thank you for a great tutorial!
@ShackMan Жыл бұрын
Sure. Performance depends on the size of the tilemap and how intensively you process it. My advice in general is to just try it out, once you have the core mechanics down, do a stress test where you increase the size/processing by 100x or 1000x and see what happens.
@remilaurent2055 Жыл бұрын
Is it possible to change the sprite of tile when it's clicked ?
@ShackMan Жыл бұрын
Yes, I have another video with how to change tiles at runtime, you can swap the tile at runtime through code.
@PeterMilko4 жыл бұрын
cool
@sjs_ujs Жыл бұрын
very good ,tsk
@alexey6343-x02 жыл бұрын
Dictionary? Ouch... That was painful.
@quadroninja27084 ай бұрын
idk, log2(n) seems like an okay efficiency
@rebelcrusader99733 жыл бұрын
Dude, it's all fine and good, but why do you add so many empty lines when coding? I have to constantly go back because your previous code gets constantly hidden by the absurd amount of empty lines you add for no reason.
@manyfailsonewin43522 жыл бұрын
some reason some ppl prefer to put their { on same line and some don't, i would guess. just little things that makes it easier for ppl to read their own code.