Creating reusable 'chunks' of tileset

NidonocuNidonocu Posts: 3Member

So I'm just getting started with Godot and I have the idea for a simulation / building game.
For the game, I want the player to buy pre-set plot areas of various types to them further build inside of.

I'm guessing I'll want to build the pre-set plots using tilemaps and then in game, the player chooses a location to place the plot in the world.

My question is how would these different tilemaps join together dynamically as part of a whole map later so things like AI people see all the plots as though it was one continuous map and can move around them.


Tags :

Best Answer

  • Dave The DevDave The Dev Posts: 13
    Accepted Answer

    Yep, as I understand it, that is correct, more or less. If you plopped down your tilemap then your actors can just be placed and moved on top of everything. Things lower in the scene tree get drawn on top. You can setup collidable tiles in the tile editor. For your actors, if it were me, I'd use the KinematicBody2D nodes. It's not impossible to use a RigidBody2D for characters, but I think you'll find the "move_and_collide" functions are nice on KinematicBody2Ds. So, yes, as long as the sprites are lower in the scene tree than the tilemaps, they would move over them like they weren't even there.

Answers

  • Dave The DevDave The Dev Posts: 13Member

    I don't have a clear idea about what you want this to look or act like, but based on the above and off the top of my head, here's how I'd start thinking about that.

    Make a grid of empty tile objects. These objects would basically act as placeholders waiting to be filled with data. When a player places a tile on one of these empty tiles, it populates that empty tile with data and behaviors. When an AI person is on a tile it is parented to that tile and all the tiles are parented to something higher, like a Node2d or Spacial or whatever you want. When an AI person wants to move within the tile, it just asks its parent if the movement is valid. If an AI person wants to move to another tile, it asks its parent tile and the parent tile asks its parent if the movement is vaild and passes its answer back down the chain. When an AI person moves between tiles it would get re-parented to the new tile.

    This may not be a perfect solution as its just the first thing that came to my mind, but it might be a good place to start from and iterate on. Good Luck!

  • NidonocuNidonocu Posts: 3Member

    Thank you for the answer! Though while that maybe helps with the AI situation I'm not sure about the actual building side of things still.

    To provide a little more clarity and context, the game idea is one involving building a space station so my idea is that the player would have a menu of modules of various types and shapes and so on to choose from. As their station expands, they add new modules to their space station.

    I'd want these modules to be fixed designs and layouts using a unified set of graphics, so it makes sense that I'd draw a module out using tiles in a tileset, which if I'm understanding how Godot works, I'd then store by its self as a 'scene'?

    Would it then be a case of simply be a case of instancing the various modules in my game world scene next to each other and any RidgedBody2D actors would happily move, collide and so on within the different modules as though they were all drawn on one tileset object together?

  • Dave The DevDave The Dev Posts: 13Member
    Accepted Answer

    Yep, as I understand it, that is correct, more or less. If you plopped down your tilemap then your actors can just be placed and moved on top of everything. Things lower in the scene tree get drawn on top. You can setup collidable tiles in the tile editor. For your actors, if it were me, I'd use the KinematicBody2D nodes. It's not impossible to use a RigidBody2D for characters, but I think you'll find the "move_and_collide" functions are nice on KinematicBody2Ds. So, yes, as long as the sprites are lower in the scene tree than the tilemaps, they would move over them like they weren't even there.

  • NidonocuNidonocu Posts: 3Member

    Thanks very much, I've tried it out and it's worked well, for others doing similar things, I will also recommend making sure the center of the tilemap is in the middle of the drawn out map, to make rotating and aligning the tilemap in to the correct orientation easier.

Sign In or Register to comment.