set_physics_process(false) not working?

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

I’m adding an opening transition animation and I want the node and its children (consisting of stuff such as kinematicbodies and such) to not do anything until the animation finishes. Only problem is that does not seem to work and the kinematicbodies still do stuff before they’re supposed to. This is on version 3.3.2

I want to ask why this could be happening and what I could do to fix this? Thanks

Code snippet below:

extends Node2D

onready var circleTransitionAnim = $CircleTransition/AnimationPlayer

func _ready():
	circleTransitionAnim.play("transition_in")
	set_physics_process(false)

func _on_AnimationPlayer_animation_finished(anim_name): 
	set_physics_process(true)

*EDIT FOR CLARITY:

My node has several child nodes each with _physics_process() functions and THOSE are the ones I want to disable. I have since tried the code snippet below but it also does not work

func _ready():
    for i in get_children():
        set_physics_process(false)

Any other solutions I could try?

*UPDATE:

I’m an idiot and forgot to make it i.set_physics_process(false) insted of just set_physics_process(false). It’s working fine now.

:bust_in_silhouette: Reply From: skysphr

It is unclear from the code snippet whether this is indeed the source of the problem, but you should keep in mind that set_physics_process() will not interfere with other functions such as _process() or _input(), signal triggers, or method calls from external sources. You need to explicitly call set_process(false) to disable _process(), as well as ignore input handling and the likes.

Sorry should have explained better.

My intent is to disable all _physics_process() functions in the children of the node. I have no _process() or _input() functions to speak of.

I have since tried to do the following in the code below but it doesn’t work either

func _ready():
    for i in get_children():
        set_physics_process(false)

*UPDATE:

I’m an idiot and forgot to make it i.set_physics_process(false) insted of just set_physics_process(false). It’s working fine now. Thanks for answering.

RZaga | 2022-01-07 01:28