I am trying to build a place where the player can’t use a specific ability. If the player enters the area, the input connected to the “attack” ability should be disabled. I tried to look for a tutorial, but I couldn’t find anything.
Code
extends Area2D
@onready var player_dungeon = $player_dungeon
@onready var playerinfos = get_node("../player_dungeon")
func _on_body_entered(body):
if body == player_dungeon:
if Input.is_action_just_pressed("attack"):
#disable attack
func _on_body_exited(body):
pass
When the player enters the area, set something like “special_attack_disabled” in the player’s class to true. When he leaves, set it to false. And check for the value before performing the attack.
If you can refactor to use _unhandled_input and events, instead of pulling with the Input singleton. You could add a hidden UI element to capture specific inputs and set them as handled. So they will not propagate down into the player and you wouldn’t need to add extra logic.
Although you may forget it’s there and wonder why your character isn’t working. I guess a log is in order