Changing the monitoring property on a child node via function call

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

I am trying to turn off my Player child node area2D Hurtbox via function to make the player invincible. The function call is triggered by an animation which calls it on a frame.

On my

onready var hurtbox = $Hurtbox

  func roll_invincibility_started():
        hurtbox.set_deferred("monitoring", false)

I have tried a few things instead of hurtbox.set_deferred such as

  get_node("Hurtbox").monitoring == false

How can I do it?

code is incorporated correctly. Make sure your ANimationPlayer calls this function using print

Inces | 2022-09-04 18:27

Kindly, could you show a code snippet of which is correct? get_node or my first snippet?

Regarding having AnimationPlayer call the function using print, you have lost me there. I have set it up as a call method track on the animation player so that the function would be called on a specific frame.

Godot_Questions | 2022-09-04 18:38

:bust_in_silhouette: Reply From: Inces

both methods of disabling monitoring are correct.
Thus, there must be another issue preventing this from happening.
By doing :

func roll_invincibility_started():
        hurtbox.set_deferred("monitoring", false)

You will ensure if your method is actually called from this animation frame