godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
89.43k stars 20.25k forks source link

Add properties to Tile definitions #14592

Closed erodozer closed 6 years ago

erodozer commented 6 years ago

The current implementation of tiles for use in TileMapping is missing a few valuable features for RPGs and other tile based game types that can be found in RPG Maker and Tiled, a key one being the ability to add dynamic properties to tile definitions in your tileset. Now that Dictionary support has been added to Godot 3's inspector, now would be a great time to add a properties dictionary to Tiles so because they can be configured and edited more easily.

Properties attached to tile types are incredibly useful for defining extra data that can be used, such as defining tile density for casting shadows in a roguelike, or saying if a terrain is mud or sand so your character will move slower in it, or saying which background to show when the player gets in a random encounter. This stuff can be done already using additional nodes like Areas and checking collision, but that doesn't lend itself well to procedural generations, or it ends up making a game that has simple grid based movement and boolean based collision become more complex than it needs to be.

x = 1
y = 2
if tilemap.get_cell(x, y) in [1, 3, 5, 6, 7, 8, 11]:
   move_to(x, y)
x = 1
y = 2
if tilemap.get_cell(x, y).properties["passable"]:
    move_to(x, y)
vnen commented 6 years ago

Duplicate of #12634