Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TileMap, TileSet feature proposal #19700

Closed
LATRio opened this issue Jun 21, 2018 · 8 comments
Closed

TileMap, TileSet feature proposal #19700

LATRio opened this issue Jun 21, 2018 · 8 comments

Comments

@LATRio
Copy link
Contributor

LATRio commented Jun 21, 2018

Current tilemaps and tilesets are very limited in terms of functionality. So, basically, they're not really useful when making grid-based RPG games (quite popular even these days) or similar games.
I tried to sort features by implementation difficulty.

Main features:

  • Ability to use AnimatedSprite2D with Sprites. Or Sprites with AnimationPlayers (Usage ex.: water/fire tiles) (Well, they can be animated by changing texture/region from AnimationPlayer...)
  • Support nodes with scripts (can function as trigger).
  • TileSet as new node type with it's own editor.

TileSet Editor features:

  • New Tile node. And ability to generate tiles from Sprites or from spritesheets with given step, offset, separation. (Reusing 'Texture Region' is fine I think).
  • Having all selected tiles visible on region picker would be nice

Optional features:

  • Visualize collisions. (Ex: When having invisible wall tiles)
  • Make grid-based movement easier, i.e. make player node aware of TileMaps existance. Probably would be better to add player node into tileset. (I know this can be easily implemented, but still...)

Well, maybe some of these features are already implemented/being implemented or exist in some other form, but still wanted to write them down, because I couldn't find them.

There are a lot of feature proposals similar to this, So, I think people would like to see some improvements in this direction.

@Zylann
Copy link
Contributor

Zylann commented Jun 21, 2018

New Tile node

That makes no sense in the current TileMap implementation. Maybe you are getting confused by the fact that Godot allows you to convert a scene into a tileset, but keep in mind that's just an editor utility, tiles are not nodes at all, and it's likely we just get a proper tileset editor in the future.
If people want tiles to be like nodes so badly, perhaps we could add a new kind of tilemap that works like a regular tilemap in terms of editor, but instances full-fledged nodes instead. It would loose the optimizations given by TileMap, but could be better suited for some games. (that could be a plugin tho)

TileSet as new node type with it's own editor.

That also makes little sense because TileSet is a resource, not a node. I think we just need a more complete editor dedicated to it rather than a scene converter and an autotile panel.

Support tiles with 1x2, 2x2 etc. sizes (Optional. Probably will have to assign main/center cell)

Note: tiles larger than a cell are supported already, though they still occupy 1 cell. Just make your tile larger and setup its center properly ;)

Probably would be better to add player node into tileset.

Difficult to make sense of this in engine, but you can perfectly make your player visual representation to be a tile in the tilemap that you set from a script.

In-Editor visualization of nodes (Only exist in editor mode and disposed of when launching and releasing the game).

Editor-only nodes? I think there is an existing issue about this already.

@LATRio
Copy link
Contributor Author

LATRio commented Jun 21, 2018

That makes no sense in the current TileMap implementation. Maybe you are getting confused by the fact that Godot allows you to convert a scene into a tileset, but keep in mind that's just an editor utility, tiles are not nodes at all, and it's likely we just get a proper tileset editor in the future.
If people want tiles to be like nodes so badly, perhaps we could add a new kind of tilemap that works like a regular tilemap in terms of editor, but instances full-fledged nodes instead. It would loose the optimizations given by TileMap, but could be better suited for some games. (that could be a plugin tho)

The reason I wrote it is exactly that: new TileMap/TileSet implementation where having separate Tile node would make sense. Converting scene with sprites into tileset won't be required if you can just create TileSet node directly.

Note: tiles larger than a cell are supported already, though they still occupy 1 cell. Just make your tile larger and setup its center properly ;)

Got it. Removing feature.

Difficult to make sense of this in engine, but you can perfectly make your player visual representation to be a tile in the tilemap that you set from a script.

I think so too. Wasn't really sure about this one.

Editor-only nodes? I think there is an existing issue about this already.

I can't find it. Will remove it if issue like this already exists.

@LATRio LATRio changed the title TileMap, TileSet & Editor feature proposal TileMap, TileSet feature proposal Jun 21, 2018
@mhilbrunner
Copy link
Member

See also: #19538

@swarnimarun
Copy link
Contributor

Ability to use AnimatedSprite2D with Sprites. Or Sprites with AnimationPlayers (Usage ex.: water/fire tiles) (Well, they can be animated by changing texture/region from AnimationPlayer...)
Support nodes with scripts (can function as trigger).

@CloudAlRio Adding the ability to have AnimationPlayer and Scripts per tile will be bad for optimisation, you can merge collision shapes, and sprites and use them as one(or in quadrants) thus having better optimisation than separate tiles.
So all those thing are become way difficult with optimisations in mind.

On the rest I am with @Zylann.

@LATRio
Copy link
Contributor Author

LATRio commented Jun 22, 2018

Why having script on one or few tiles in grid-based game would hurt optimization that much. Also those games do have animated tiles and they don't hurt optimization too much.
Anyway, closing issue with proposals because they seem to be pointless and bad for optimization.

@LATRio LATRio closed this as completed Jun 22, 2018
@vnen
Copy link
Member

vnen commented Jun 22, 2018

Why having script on one or few tiles in grid-based game would hurt optimization that much.

It would still have to check every tile to see it has a script or not.

Also those games do have animated tiles and they don't hurt optimization too much.

Animated tiles are planned. They can be accomplished by creating an animated texture. It's not the same as an animation player per tile.

@swarnimarun
Copy link
Contributor

@CloudAlRio Having anything other than textures will mean bad for optimizations for it will not be consistent thus will have to check each tile for scripts and stuff they will not be bundle together properly then.
And visualising collisions is already there(turn debug collision shapes on), but doesn't work in the Editor(run the game to see the collsions), I don't really know why at the moment.
Should not be impossible to implement.

Overall I like that you tried to put up a good and descriptive proposal here. You seem to have some ideas but just don't seem to know how it could be proposed.
Try talking to some people on Discord server to help with it and then create a proper one.

@nightblade9
Copy link
Contributor

I, too, would like to add scripts to tilesets. I brought this issue up on Discord and received two pretty good answers:

  1. Tilemaps are created for efficient drawing of large amounts of tiles. When you add scripts to a lot of tiles, things start to slow down, fast.
  2. The current recommended approach is to iterate over all tiles, remove the ones that have logic, and add a scene in that location.

For example, in my game, I have trees that you can chop down. So, I would:

  • Create a basic tree tile in my tile map, with a collider
  • Create a Tree entity (scene) with all the logic/scripts in it
  • Write map code that iterates, looks for the tree cells, removes them, and attaches a Tree entity in that place

Here's some helpful code I got from Discord (disclaimer: I didn't try running it yet):

	func build_stuff():
		for cell in $StuffMap.get_used_cells():
			if get_cellv(cell) == TREE_ID:
				spawn_tree( $StuffMap.map_to_world( cell )
	
	func spawn_tree( cell ):
		var t = preload("res://tree.tscn").instance()
		world.add_child( t )
		t.position = cell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants