0 votes

I have been following the documentation and setting up some simple movement code. In the documentation physicsprocess(delta) is used, which seems to work fine, but Godot flags an error:

W 0:00:00.538 The argument 'delta' is never used in the function 'physicsprocess'. If this is intended, prefix it with an underscore: '_delta'

The documentation doesn't seem to mention _delta, or what the difference is here. Can anyone explain?

Thanks

Godot version 3.3.2.stable.official
in Engine by (15 points)

1 Answer

+1 vote
Best answer

There is no difference, it's just a variable name. You could change it to anything you wanted and it would still work the same.

The point of that message is that it is letting you know you're not using an argument that was passed to the function. That may be fine - it's just a warning.

However, the warning system will ignore arguments whose names start with _. So if you don't plan to use the delta value, you can rename it to _delta and the warning will go away.

by (21,577 points)
selected by

Thanks for the reply!

Using move_and_slide() which I understand automatically uses delta, within physics_process - is it necessary to include delta as an argument?

eg. _physics_process() vs _physics_process(delta)

Also just to confirm, if it is necessary to declare it, does using _delta only affect the warning system and not the functionality of the code?

You can't just write

func _physics_process():

Because the engine calls the function and passes the parameter. You'll get an error, it's not optional.

And yes, the name of the argument doesn't change anything. it's a variable. You can write:

func _physics_process(bananas):

And now bananas will have the value of the frame time that the engine passes to the function.

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.