Topic was automatically imported from the old Question2Answer platform.
Asked By
GamesByMike
I’m reading from the official Godot 4 docs on the part of coding the player choosing the animations.
Here is the code part I am using to change the animation
func _process(delta):
if Input.is_action_pressed("right"):
$Sprite2D/AnimationPlayer.animation = "walk"
But when I run the game and press right the game crashes.
and the error says
W 0:00:00:0694 The parameter 'delta' is never used in the function '_process'. If this is intended, prefix it with an underscore: '_delta'
<GDScript Error>UNUSED_PARAMETER
<GDScript Source>CharacterBody2D.gd:31
The “error” you mention isn’t an error at all. It’s just a warning telling you that the _process() function has an input argument (delta) that you are not using in the function (which isn’t typical). That said, it is just a warning and you can safely ignore if you didn’t intend to use the argument. There are a number of ways to tell the engine that you don’t want to be warned about this case. A simple way, as suggested in the warning message itself, is to simply rename the argument to _delta. So…
func _process(_delta)
That underscore will tell the engine to no longer warn about that specific argument.
So, while interesting, this has nothing to do with a “crash”. If you’re really getting a crash, you’ll need to provide some additional info.
Ok, the underscore was just a typo. But the game still crashes when I hit Right.
Here is a screenshot of my screen when the game crashes.