idk how to do a area that makes the character slower when he touches it

Godot Version

4.6

Question

i tried to do an area2d where u got slower when you were inside of it but it doesnt worked and i dont know why

extends Area2d

   const spped = 300
   const slow = 150
   const speed = spped


func  area_entered(body)
if body.is_in_group("player")
player.speed = slow

func area_exited(body)
if body.is_in_group("player")
player.speed = spped

You have not posted enough code to evaluate the issue.

We need to see the player.

1 Like

How does it not work? Do you get an error? What do you expect to happen versus what really happens?

use whatever you use or collision, but check for a specific tile and slow the speed when on that tile.
*This is assuming you have collision with raycasts, this could easily be the most useless attempt at help here, i should probably have more caffeine.

Add prints to check if the functions run as expected.

1 Like

Your trying to change a constant. That’s gonna cause issues. Make speed a variable.

1 Like

i expected the character slow down after i touched the area collision but in fact nothing happened