The system is built by selecting a block using a hot panel

Godot Version

4.2.1

Question

Hi! I would like to know how I can create a construction system by selecting a block through a hot panel in 2D TopDown

Explain what you want to acheive in more detail or it will be very hard to help you.

Sorry. I have a hotbar and I would like to know how to select a specific block and then place it on a tilemap in 2D Top Down.

Let’s say I selected a certain block and then was able to place it on a TileMap.

If you have already made the selector for it, all you need to do is have some kind of mapping that tells you which tilemap tile corresponds to the item in the hotbar and then create that tile in the tilemap.

Thanks!

I would like to know if you have an example of how to implement this? I’m trying to figure out how to put a block directly from the hotbar on Tilemap :smiley: I’m still new to this plan.

Show what you have made and we can work from there.

I have a hotbar like in this video (I decided to throw off the video because it has everything at once and I don’t have to throw it in parts, but I hope it will be more convenient for you?)

Based on this I think the things you have to do are something like this:

  • Add “Tile” to the type enum in the Item script so it can be different from weapons etc.
  • Create an abstract_item_tile class that is similar to the Weapons, but when activated it places a tile instead. It will use the “Tile” enum value instead.
  • Add a var tile to your item tile script. The type of this should match whatever type your player-placed objects use. (You’ll need to create that at some point if you haven’t)
  • When you place a tile, you want to change the TileMap you are on at the position you are on, using the information of this tile variable in the item tile.
  • Make instances of this object when you want to give a tile to the player, making sure to set the variable that tells which tile it is appropriately.

If you have more questions, go ahead. This should be enough info I hope.

1 Like

Thank you very much! I will try to do this and if anything, of course, I will ask questions :slight_smile:

Hi! There is one more thing I would like to know about. I am trying to implement a system of interaction with each subject through a hot panel. For example, you can choose a sword to strike, a block to build, etc. I have tried to implement this using what you have explained, but so far I have not been able to do it completely. How can this be implemented? I also tried to do this using other videos from this developer, but it turns out with errors.

If you have separated the visual representation from the data, all you need to do is find which item is in the selected slot and call the action that item should perform when used.

Could you give me an example? When I tried to implement this, the function was running for all item and slots :frowning:

I believe in you. You can use logic and deduction to figure out how to call a function only for the currently selected item slot.

Do I understand correctly that it is worth using the “Weapons” node and creating Tiles instead as an example? I have seen in other lines use_item(): however, when you try to add an action to them, it is activated for all items

Show your actual code or I can’t help you any more than I did.

I tried to combine three videos of this youtuber, but at the moment I decided to go back to the first one, so everything in this video looks like mine. However, if you want, I can throw off the combined code, but there may be a lot of errors

I’ve seen another new guide right now. I noticed that “Skill” like in that video can be like interacting with objects, right?

slot.gd
image
image
player.gd
image
I tried to redo the “Skill”, but when I try to activate it, I get these errors. In this video, the “Skill” was used as an animated sprite, but for me it is a separate node.
image
item_database.gd
image
However, when starting the game, the script is triggered only for this item, but when reused, the game crashes:(
image
upd (It turned out that the script (123) runs when the game starts, and not upon activation)