(SOLVED)How to make tilemap block grid like movement

I was trying to make a taking/making mechanism with a tilemap like this by vegetato :AutoTile Extension Example | Play on gd.games

but i cant figure how to make the blocks, and i want it to be like grid movement.

(i figured out how to take blocks tho)

screenshots:


so umm my events do sort of work, only if the blocks are placed like this

u
if see where the arrows are pointed

for some reason it allows to build in there.

if any other way pls say coz it dont look nice seeing those blocks up there.

Also i wanna know how to not let it over write placing the blocks,

like placing a block on a block i dont want that.

I believe if you create a tilemap in the size you want, it will only change the tiles in that area. You can create a tilemap using a background or just a transparent tile. You need at least 1 tile in the top left and one in the bottom right to define the size.

You can also adjust the number of rows and columns at runtime.

Alternatively, you could add an object to define the draw area. You could then either compare the X and Y to the bounding box or check if the cursor is inside the draw area object.

I like the hidden draw area object approach but defining the tilemap size and position is also good and simplier.

To prevent tiles from be altered, you can check the ID of the tile at the cursor position.

Edit: I had grid instead of coordinates. Also, unless you design the tilemap with say tile 0 as the default tile, you would need to compare the tile value of the tile(s) that you’re adding. You could check the individual tiles or a range like >5 and <13. An empty tile seems to be -1. That might also work if you deleted tiles. Then you could check if the tile ID equals -1 or the default background ID before changing the ID.

The test draw area would have to be smaller than the actual draw area by a block on each side since it’s only checking 1 position to see if a block can be added. It’s not checking if the tile fits inside the draw area just part of it.

2 Likes

what behaviours do u have on the tile map?

is it a grid something?

The tilemap doesn’t have any behaviors.

WHAT?

then how do u add the grid like movement and the platform thing

If you’re using it as a platform then you need the platform behavior. I didn’t know what you were doing with it. What is the grid movement for?

1 Like

well im not 100% sure, i thought u need it to move like its in a grid? or does it do that bit itself?

The tilemap is setup as a grid if that’s what you mean. You can change tiles using the screen coordinates or the grid column and row. The screen coordinates are converted to the grid column and row.

1 Like

one more thing,

I want the block if its directly underneath a block with ID 0 i want the block under it to be replaced with another block

You can compare the tile under the cursor as in my example. If tile ID = 0 then change the ID to whatever.

1 Like

umm i tried but im not sure which conditions to use.

can u show me?

It’s in my earlier post. You don’t need to use the draw zone condition. That was just a thought.

Edit: corrected screenshot.

You might need a trigger once or you could use mouse released. Your choice.

1 Like

it dident work even tho i did exactly what u did

Is the tile ID at the location 0? If there’s no tile I believe the tile ID is -1.

1 Like

no tile id 0 is the normal one the grass block, tile number 140 is what i want to go under the grass block.

OK. You used grid location. You need the other condition, by coordinate. Grid used column and row, coordinate uses scene coordinates.

Sorry, my screenshot was wrong. I’ll update my earlier post.

Just a tip. I wish they would allow you to name tile IDs instead of using row, column or X, Y. You could use like grass or wall. You can make things more readable by using a variable instead of the tile number. You could use like Grass =0 and Stone = 120. Then your event could be if tile ID = Grass then set tile to Stone You could put the tiles into a structure to keep things more organized. You also wouldn’t need to remember that the stone tile was 120 and a brick was say 55.

Screenshot_20251218_084244_Chrome

Using a variable would also allow you to use the same events with different tile IDs stored in a variable like CurrentTileID.

If something happens set CurrentTileID to Tile.Grass

If you had sprites with icons that represented objects like diffent types of grass or different building materials, you could create a sprite object variable that could be used to set the Current Tile ID. You could also use the animation name to get the structure name dynamical. IDK how comfortable you are with variables like structures.

Say you had an object named “Materials” You could added a named animation for each material.

And then save the selected animation into a number variable like CurrentID. That variable could be used to change the tile IDs.

Using variables gives you more flexibility, it makes events clearer and easier to understand your intentions and it allows you to just change the variable value instead of using different events or change the value so it changes the value used by multiple events.

I probably should start a new thread with a more general topic of tilemap. I just wanted to add my thoughts.

I guess you could also make a toolstrip of textures using another copy of the tilemap object. If it shares the same image or atlas, the tile IDs would be identical. If you clicked on a tilemap with grass at the clicked tile then you could save that tile ID number and use it with the other tilemap. That would keep everything in sync.

1 Like