So i’m currently in the process of creating an experimentational platformer game, and i’m trying to get more familiar with tilemaps and i’m wondering if there is a way to utilize the tilemaps to change how the player moves on it. For instance, if I have 1 tileset of normal ground it is just normal movement, but if I say have another tileset of Ice platforms, could I make the player’s friction very low, or even a swamp level that poisons the player if they touch water and slows them down?
My current workaround for this is any hazards such as spikes are their own separate node with a collision box, and if I want to change speed of the player I utilize a PlayerMovement script with separate .tres resource files attached to it that I swap out on the player which seems very clunks if I were to do a larger game down the line.
You could make all tiles extend a scene that has a variable that controls how fast the player moves on them. Then you add the scenes to the TileMap with a scene collection. Then when the player moves onto the tiles they can retrieve the speed from the tile itself.
You could embed your informations (spikes, poison, movements, etc.) in TileData. Search for “godot tile data” on youtube, you should easily find some tutorials on how to setup tile datas in editor.
Then, in your script, you can access these datas :
# in PlayerController.gd :
func process_tile_effect():
var current_tile = tile_map.local_to_map(global_position)
var data = tile_map.get_cell_tile_data(layer_id, current_tile)
if data:
var has_spike = data.get_custom_data("spike")
var poison = data.get_custom_data("poison")
var movement = data.get_custom_data("movement")
# ...
# then do something with your datas