0 votes

I'm running into a problem with the Godot application where the _physics_process function of my scene is being called while my game is not running.

For example, If I have:

func _physics_process(delta: float):
    print(delta)

My output will be flooded with 0.016667 even while my project is not being played.

The MainLoop Documentation says:

Upon the application start, a MainLoop implementation must be provided to the OS; otherwise, the application will exit.

I would think this means that the OS is passing a main loop implementation for the engine to use when you play a scene, not while you're using the Godot application.

I've made a scene for a character with keyboard controls.

func _physics_process(delta: float):
    if Input.is_action_pressed("ui_up"):
        move_and_slide(global_transform.basis.z * speed)

My character will move around in the scene while I'm typing in the script editor since I'm occasionally hitting movement keys while coding. This feels very wrong.

Am I misunderstanding something or is this a bug?
Thank you for any help.

in Engine by (56 points)

1 Answer

+2 votes
Best answer

It sounds like your script has been defined as a tool script - which is intended to run inside the editor.

Does your script have the tool keyword at the top? If so, that's the issue. See here for more info:

https://docs.godotengine.org/en/stable/tutorials/misc/running_code_in_the_editor.html?highlight=tool#what-is-tool

by (10,914 points)
selected by
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 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 webmaster@godotengine.org with your username.