Is there a way to connect the activation of an Area2D node to an input?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Sabir_The_Trubbish

I need to do this because I want to have a shield in my game. Any help would be greatly appreciated.

:bust_in_silhouette: Reply From: Inces

You can use monitoring property of Area2D or disabled property of its collision shape

I’m sorry but, I don’t really know how to use this information properly. I’m relatively new to the engine and language.

Sabir_The_Trubbish | 2022-05-09 18:38

func input(event):
       if input.is_action_pressed("shield_up"):
             $Area2D.monitoring = true
       elif input.is_action_just_released("shield_up")
             $Area2D.monitoring = false

So pressing input for “shieldup” activates Area, and releasing it deactivates the area
this is not syntax-perfect, but You should get the point. Instead of $Area2D.monitoring You can use $Area2D/CollisionShape.shape_disabled to true or false. There are many more options. Always read about nodes methods in editors built-in documentation

If You still don’t get it, You definetely need to dig into some basic tutorials first

Inces | 2022-05-09 19:03

Thank you for your help. The documentation really helped too. :slight_smile:

Sabir_The_Trubbish | 2022-05-10 01:35