thx for answering but sorry that’s not what i meant, in this case i wanna make my character has a skill to slow all the enemies for a while before returning their speed back(with pressing button), so i need to change the variable value more than once
when the area triggers, you can check collided object for specific properties.
# this is an enemy
func _on_Area2D_area_entered(area):
if(area.is_in_group("DecreaseSpeedMagic")):
speed = 2
$SpeedResistanceTimer.start()
After check, i would set a Timer for how long you want to decrease the speed.
func _on_Timer_timeout():
speed = 4
/// if you want to control that from player side you could do is like that:
func _on_Area2D_area_entered(area):
if(area.is_in_group("Enemy")):
speed -= 1
area.resistanceSpeedTimer.start() # to reset is to normal speed after a while.
Some code like that, could work for an ice spell or something like that.
edit: dont know how to create the code snippets, so Im sorry for my code xD