Slow down on touching water tiles

Godot Version



Hello! i am trying to make a mini top-down survival game, and i have a procedurally generation system with fastnoiselite, im not sure what most of it is and have very little understanding how it works as im really new to game coding.

i would like to make it so when my player touches a water tile, they slow down, i also want to use tile ids to identify the water tiles!

Here is my code for tilemap generation:
extends TileMap

var moisture =
var tempature =
var altitude =
var width = 25
var height = 25
@onready var player = get_parent().get_child(1)

func _ready():
moisture.seed = randi()
tempature.seed = randi()
altitude.seed = randi()

func _process(delta):

func generate_chunk(position):
var tile_pos = local_to_map(position)
for x in range(width):
for y in range(height):
var moist = moisture.get_noise_2d(tile_pos.x-width/2 + x, tile_pos.y-height/2 + y)*10
var temp = tempature.get_noise_2d(tile_pos.x-width/2 + x, tile_pos.y-height/2 + y)*10
var alti = altitude.get_noise_2d(tile_pos.x-width/2 + x, tile_pos.y-height/2 + y)*10

		if alti < 2:
			set_cell(0, Vector2i(tile_pos.x-width/2 + x, tile_pos.y-height/2 + y), 1, Vector2(3, round((temp+10)/5)))
			set_cell(0, Vector2i(tile_pos.x-width/2 + x, tile_pos.y-height/2 + y), 1, Vector2(round((moist+10)/5), round((temp+10)/5)))
1 Like

Just an idea but maybe the water tile contains an Area2d which, when the player enters the area. A signal is sent to whatever level node you are using, the level node catches this and sends a signal out to the player, which then catches the signal and changes a modifier for its speed.

I’m pretty new to Godot and am unsure whose responsibility it should be regarding these things. My current understanding is that it’s likely only the level can “see” both the player and the tiles at the same time, so it’s the level’s responsibility to handle signals between the two.


Area2D can set override physics within their space. That is to say, if you are using 2D physics associate an area 2d with the water tile and increase the linear_damp. This will increase “friction” and slow the player that can collide with it.

If you aren’t using 2d physics then you will have to manually change the movement mechanics with an area entered signal of the Area2D to the player as @joebog96 has suggested.

1 Like

Your solution seems simpler and should be used in preference to mine. Sounds like it’ll also work on other rigid bodies that go though it, which is probably what you’re looking for as well.

In addition to this, one can paint different physics layers on tiles in a tile set. You could paint a physics layer on the water tiles that alters the movement speed of the player when the player collides or enters its space. You don’t need an Area2D with this.