Hot answers tagged

3

I arrived here by Googling this problem myself, read the linked articles, and produced a relatively compact solution which generates the common set of 47 tiles. It requires a 2x3 tileset for the autotiled material like this: With a single-tile variant at the top left, inner corners at the top right, and four outer corner tiles at the bottom (you may ...


3

Just download this script AnimatedTile and put it into your project, then you can find AnimatedTile at Create > Tiles > Animated Tile. In case you don't want to click the link, I copy the script for you using System; #if UNITY_EDITOR using UnityEditor; #endif namespace UnityEngine.Tilemaps { /// <summary> /// Animated Tiles are tiles which ...


3

Here's an example of depth-first search implemented in python, finding all squares of the same type and connected to a given input square: maze = """\ ********* * * ** * D * **D*** ** * * ** * ** * ** D * *********""".split('\n') dr = [-1, +1, 0, 0] dc = [0, 0, -1, +1] def all_tiles_of_same_type(maze, r, c): tile_type = maze[r][c] ...


2

This is the "Visible collision shapes" option from the Debug menu:


2

As far as I understand your question, you want to compute the regions of your map that would be flood-filled in a paint program. In that case, I recommend one of the following approaches: https://en.wikipedia.org/wiki/Breadth-first_search https://en.wikipedia.org/wiki/Depth-first_search https://en.wikipedia.org/wiki/Disjoint-set_data_structure In case of ...


2

The recommended way would be to override Node._unhandled_input() and use TileMap.world_to_map() and TileMap.map_to_world() methods. Example: # tile_map.gd extends TileMap func _unhandled_input(event): if event is InputEventMouseButton: if event.button_index == BUTTON_LEFT and event.pressed: var clicked_cell = world_to_map(event....


2

The rotation comes from the calculation of the index in load_from_file(), it should be: chunk[i][j] = std::stoi(tokens[i * Constants::BIOMESIZE + j]); That said, it would be much better if you could save the file in such a way that you can load it back the same way. Instead of using "," as a separator, use a space (" "). Then you can ...


1

It is an old question - There doesn't still seem to be easy way to show clearly the origin and the bounds of a Tilemap, but it can be solved with a script that runs in the Editor like Philipp said. I created this script. Red border shows the Tilemap current bounds, green cross shows the 0,0,0 position of Tilemap. Script does take into account position of ...


1

Thanks to @DMGregory, i've Added the parametter samplerState on SpriteBatch.Begin that fixed everything SpriteBatch.Begin(transformMatrix: DisplayOffsetMatrix, samplerState: SamplerState.PointClamp);


1

I personally would simply not include stuff like your character sprite into your texture atlas. There is no need to actually go so far and combine you whole game art into a single atlas. If you look at what the big 3D Engines do, they also have unique textures(even multiple ones) for each Mesh and are still able to render quite a significant amount of them. ...


1

If you want to know what tile is at a particular location, you can just ask the tilemap. Then you can use that tile to look up into a mapping of which effect to call: using System.Collections.Generic; using UnityEngine; using UnityEngine.Events; using UnityEngine.Tilemaps; public class TileCollisionEffect : MonoBehaviour { // Define what kind of script ...


1

Thanks to @DMGregory, the solution for anyone else with the same question is as follows: Find the sprite in your project Open the sprite editor from the inspector Edit the collider If you don't set any collider here, it appears Unity will figure it out for you instead.. which in my case was not appropriate. I just made my collider into a box.. as follows: ...


1

Conventional auto-tiling strategies aim to simplify the selection of individual tiles where two different terrain types adjoin, using rules that are local and deterministic: Local: only the tiles/edges/corners immediately adjacent to the one being selected can affect the decision, so the features it controls are small and don't have much internal structure. ...


1

That particular guide is a few years old. In recent Unity versions, this button has been renamed, but it's still in the same place: Select your spritesheet texture Open the Sprite Editor Click the drop-down labelled "Sprite Editor" in the top-left of the window Choose "Custom Physics Shape" from the drop-down menu


1

There is never a best solution. Only the solution which is best for your game and your personal workflow. However, I would suggest a third solution. One scene only Store every map as a prefab (The Grid object with the tilemaps and all the objects on the map) When the player switches maps, destroy the old map and instantiate the new one. Why only one scene?...


1

To make the noise tile, all you need is to ensure that the gradient you select for integer point (x, y) is the same as the gradient point you select for (x + j*tileFrequency, y + k*tileFrequency), where tileFrequency is the number of grid cells across your tile. (See this answer for a bit more illustration of how this gets us seamless tiling) Inside your ...


1

some of your ideas are good, some are terrible... Data Model first you have to create a proper design - that means you have to think about what data you have and how they interact - this part is missing yet (as far as i can see from that question) Architecture as you are a beginner i suggest you try to achieve something like a M-VC (Model-View-Control) ...


1

It turns out, that if the Tilemap's object is disabled, WorldToCell will always return (0, 0, 0)


1

This can be achieved with the update_bitmask_region() function in the TileMap class. Calling it with no parameters will update the whole tilemap, which is probably what you want.


1

There are roughly two ways of doing autotiling - either the autotiles are counted as separate tiles and are then edited/inserted "offline", with the game rendering the required pieces straight off the map, or the tiles are stored without the information and it is only calculated and stored in memory (think how Minecraft fences work - the level files only ...


1

When you have pure tile-based yes-or-no walkability, then there are a lot of optimizations you can do because: Tiles never move Tiles always have the same size Tiles are always found at coordinates which are multiples of the tile size Your collision system doesn't need to check every tile for collisions with entities, because tiles won't move and won't ...


1

If you want to keep things simple, I would pick a format and stick to it. The two most simplest image formats that I know of are: PPM BMP TGA It's not that difficult to implement loading of any of these files. I see PPM files used a lot in ray tracing examples because the file format is so easy to handle. If you're the one generating these images, I'd ...


1

I think this is more an opinion-based question but here are my thought (I'm not a C++ expert): Create a base class Tile that will handle generic stuff like rendering, animations if any, behavior of the tile... For each of your special tiles, create a new class that inherits from your base class Tile and override the behavior if your new tile has a custom ...


1

From generative code, if you have less than 100 levels, you can save the levels as unity assets / prefabs and load them instantly using a bit of scene management, level code and choose the 100 best that you prefer. If you have an animation of a level transition, which rewards the player, it can give you a few moments for him to chill out while you do the ...


1

Perlin and Simplex noise are both forms of gradient noise, meaning at each corner of a grid, they pseudorandomly choose a gradient vector that determines the rate of increase of the output value in the neighborhood of that point. So you can use this to establish an upper bound on how much the output can increase over a distance of one heightmap cell, ...


1

You already mentioned the two broad solution categories. Here are some specifics about each. Capping the values as they are generated: The potential problem with this is that depending on your implementation, you need to be careful about checking values before they are assigned. For instance, the very first value generated won't have any neighbors yet. Also,...


1

I guess you should read the manual, how Unity Tilemap is structured. If you create a Tilemap in Unity Editor, first you have a Grid and then a Tilemap under it. If you move Grid, Tilemap will move along it. This same thing is true for getting tiles in code. Tiles are stored in GridLayout space not in world space. So if you happen to start "drawing" you tiles ...


1

You can design each event room on a separate tilemap and then save that tilemap as a prefab. Those prefabs can then be referenced by ScriptableObject's or directly by the script which does your dungeon generation. If your architecture allows for more than one tilemap, then you could simply instantiate the event rooms. This would have the advantage that the ...


1

"Pack all the individual Sprites that make up the Tilemap into a single Sprite Atlas to solve this issue. To do this: Create a Sprite Atlas from the Assets menu (go to: Atlas > Create > Sprite Atlas). Add the Sprites to the Sprite Atlas by dragging them to the Objects for Packing list in the Atlas’ Inspector window. Click Pack Preview. Unity packs the ...


1

After a while a found an answer. So the Tilemap instances have its own origin position in their parent grid object which can be accessed with <Tilemap instance>.origin. The origin position is equal to its minimum bound point after you compress the tilemap's cell bound. So you can get the exact center world position of each tile in a tilemap by ...


Only top voted, non community-wiki answers of a minimum length are eligible