Gdscript 's adaptation

<v4.2.2>
Why the completion of gdscript can generate error in editor ? I was following Brackeys ‘s course ,when using “func _on_body_entered()” the completion was body . But when I try to run it , it happened. It telled me “it never used in function” , I should change it as"_body" , but that was the official completion. So you just update the version of the editor , but didn’ t do the adaptation

1 Like

First of all, this is not an error, is a warning (an error is a problem you need to solve, a warning is more: “This could be done better, but if you don’t want, no problem”)

Second and most important, the completation code can’t guess what you’ll do in this code, body_entered signal call a function with one argument (body) and completation needs to create this parameter no matter if you’ll use or not, and 95% of times you’ll use the parameter received in the signal. So why auto mark the parameter as unused if most of times you’ll use the parameter and most important, the completation doesn’t know what you have in mind?

1 Like

This isn’t an error, just a warning that a function parameter was never used. You can ignore it or suppress the warning by adding an underscore to the parameter name, just like you did.

1 Like