The 2024 Developer Survey results are live! See the results

# Tag Info

## Hot answers tagged tilemap

Accepted

### Best practice for map coordinate system

Most games place the map origin in a corner. The main reason for this is that tilemaps are often internally stored in two-dimensional arrays, and most programming languages don't allow negative array ...
• 121k
Accepted

### How to get all tiles from a Tilemap?

To get an array with all tiles from a rectangular area of your tilemap, use tilemap.GetTilesBlock(BoundsInt bounds). You will get a one-dimensional array of tiles, ...
• 121k
Accepted

### What is the size limit to the Unity 2017.2 Tilemap?

Your RAM is your limit. The following tests were performed on a system with these specs: Intel i5-6600 16 GB RAM NVIDIA GeForce GTX 1070 Windows 7 Home Premium Here is a script I ran which grows a ...
• 121k

### How to get all tiles from a Tilemap?

Here is another way to do it with .cellBounds.allPositionsWithin ...
• 281
Accepted

### Player gets stuck on edges between TilemapCollider2D tiles

After trying to write a code that merges the squares effectively (especially for large Tilemaps) both horizontally and vertically I decided to look if there is a better suited collider than the ...
• 371
Accepted

### How can I fill the interior of a closed loop on a tile map?

Short: After completing the shape you should have a multiple of 2 Points for each affected row on your x-axis. From there it becomes just a matter of splitting up these Pairs of Points for each row ...
• 2,062

### Best practice for map coordinate system

In theory the location of the origin doesn't matter. All math operations you do when the map is rendered or when objects move on the map work fine regardless of where the origin actually. However in ...
• 2,353

### Is there a name for this technique to put the tiles on the corner of a level?

It's a palette. Same thing you see some artists doing with colors. They draw a group of a couple of the main colors or even a gradient going between them for easy access. It's much easier to use a ...
• 15k
Accepted

### How can I procedurally find a wall that separates two or more points on a grid-based map?

I will present a general concept and three solutions using that concept. Concept is an Influence map: For each location in the map, you are going to store a number that represent the distance to each ...
• 27.3k
Accepted

### Strange warping/shimmering effect with Unity Tilemap and Cinemachine

Note that Cinemachine now has a Pixel Perfect extension that automates the kind of camera calculations I describe further down in this answer. Consider using that, and check the rest of this answer ...
• 136k
Accepted

### Is there a name for this technique to put the tiles on the corner of a level?

I don't know if there is a name, but this seems to be something you'd do to conserve memory. First, a basic tile is very low resolution - just a few pixels across. But when rendered, they are ...
• 10.3k

### How can I deal with tilemap position in the editor?

The select tool. Clicking any tile with the select tool, the inspector will tell you the position relative to 0,0. With a little bit of math (and/or additional clicks), you can hone in on whichever ...
• 171
Accepted

### Tile palette off-centered

I fixed it by: 1.) Deleting my current tiles in the tile palette. 2.) In the inspector, after selecting the sprite that I wanted fixed properly on the tile palette, I changed the sprite's pivot ...
• 86
Accepted

### How do I sort edge tiles for a hex grid in order to draw a border?

The usual approach here is to pretend like you're solving a maze blindfolded: keep your left hand in contact with the wall, and follow its contours until you reach the exit (or in this case, until you ...
• 136k
Accepted

### How can I generate infinite boundary walls in PICO-8?

Sounds like you want to animate the walls down the screen so that it appears as though the player's ship is moving forward. Know that the PICO-8 Map is mainly for static backgrounds, so if you want a ...
Accepted

### Positioning tile sprites so they connect seamlessly

Using the Move tool (not the RectTransform tool) (Image from Unity docs) Hold the V key to enable vertex snapping, and hover over the corners of your sprite. The transform gizmo will snap to the ...
• 136k

### Big maps with deep zoom and pan

If you have access to shaders, you can invert the drawing logic. Normally you loop through tiles and draw each one. When you're zoomed out there are a lot of tiles to draw. Zooming out is slower. ...
• 6,066

### Elegant autotiling

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 ...
Accepted

### Reason for white lines in tile-based game

These lines are caused by the interpolation in the texture sampler which samples texels from adjacent tiles in your tile atlas. Both bilinear and trilinear (mipmaps) interpolation (and some rounding ...
Accepted

### Efficiently updating building effect radius coverage

Caching building coverage The idea of caching the information which buildings are in range of an effector-building (which you can cache either from the effector or in the affected) is definitely a ...
• 121k
Accepted

### Map generator sometimes doesn't work

You get an infinite loop. The statement that increases your counter in the while loop is inside an if statement that checks if the position is in bounds. Else it just sets ...
• 166

### How do I sort edge tiles for a hex grid in order to draw a border?

I see you already have an answer to your question, but I'm going to add another answer for anyone who's trying to solve a simpler variant of the question. Civilization puts borders between hex tiles ...
• 6,066
Accepted

### How do I bitmask these tiles?

Your tileset is not ideal to use for autotiling, as many common pieces are missing, for example the L shape. I modified the tileset and used 160x160 wide tiles, this is the result: The blue ...
• 331
Accepted

### How do I place objects so they snap to my TileMap in Godot?

Godot snaps to the grid guidelines and not the cells between them. So you won't snap to the middle of the square that you're dragging to. That's because you're snapping the position of the object (...
• 878

### Create a seemless grid-based polygonal tileset

This can be done with a generalization of Wang Tiles or Corner Tiles. These associate labels with the boundaries of a tile, and enforce the constraint that two tiles that meet along a particular ...
• 136k

### Drawing huge amount of tiles in Monogame (XNA) efficiently

Graphics cards are optimised to draw a few things lots of times rather than the other way around. In your case, you have a lot of things (different textures) that you want to draw a lot of times (...
• 605
Accepted

### Array-based tilemaps and bounding box (aabb?), how to do efficient tile collisions?

The reason there isn't a standard AABB or partition strategy for tile-based maps is that it's already easier to detect collisions against it than using AABBs. ...
• 9,029
Accepted

### How to make a noise gradient?

Here are two different ways I might approach this problem, showing how they change as the effect intensity is cranked up & down. The outermost column on each side is just my gradient, computed as ...
• 136k