This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

I am wondering if there is a way to disable the physicsfunction(delta) function. I tried using set_process(false) and that didn't work.

Godot version 3.5
in Engine by (12 points)

What's the goal exactly? If you don't want the function to do anything, don't put any code in it. I assume that's not what you're after, but I'm not sure I understand the ask.

I have some code in the physics process delta function but I want to disable that code because when the player dies and does its death sequence it keeps following the code under the physics process function and I don't want it to do that.

So, in that case, you probably want to just put some sort of boolean guard around the logic you want to "skip" when your player dies. Something like:

var alive = true

func _physics_process(delta):
    if alive:
        # do normal "alive" processing

Then, when your player "dies", just set the alive variable to false to skip the _physics_process() logic.

That worked thank you so much

2 Answers

0 votes

So, based on the above discussion, the answer here is to put a boolean guard around the logic in question to only run the code when appropriate. Example transferred from above:

var alive = true

func _physics_process(delta):
    if alive:
        # do normal "alive" processing

Then, set alive to false when the player dies and the associated _physics_process() code will stop exeucting.

by (22,704 points)
+1 vote

Alternatively you could use set_physics_process(false)

by (376 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.