Tutorial Final Scene will not work

Godot Version

4.6

Question

I am stuck on the last part of the tutorial. Keep getting an error: Invalid call. Nonexistent function ‘start’ in base ‘Area2D’.

This is where the error indicator is pointing:

func _new_game():score = 0$Player.start($StartPosition.position)$StartTimer.start()

I have looked at the player (Area2D) node and everything seems good. I have the start code in there from the tutorial:

func _start(pos):
position = pos
show()
$CollisionShape2D.disabled = false

I don’t know what else I might be missing.

Also, the engine keeps telling me that (delta) is never used without an underscore in front of it, but the tutorial didn’t mention that. Is there something there that I’m doing wrong?

Yes, I am a clueless noob. Thank you for any help.

Can you link the tutorial?

if the function is called _start than you have to use the name with the underscore when you want to call it.

func _new_game():
    score = 0
    $Player._start($StartPosition.position)
    $StartTimer.start()

The underscore is used in functions to mark them as private (not used outside the class). There are no real private functions in gdscript, it’s more a rule. As you call it from another class (script) you use it public, so the underscore is not correct in the name of the function. Remove the underscore in the name of the function or add it to your function call.

But for parameter like “delta” you get a warning, that it’s declared but never used in code. To ignore this warning you can add the _ to the parameter name. It tells Godot “yes I know that it’s not used, will need it later”.

1 Like

Here it is, thank you.

If I look at the original code:

There the start function has no underscore.

func start(pos):
position = pos
rotation = 0
show()
$CollisionShape2D.disabled = false

1 Like

I fixed that. It was a leftover from last night when I was trying different things to get it to work. Game still doesn’t want to start.

Than check the new error message. And compare the faulty line with the source code:

Does the rest of the code work? Is the script attached to the player node? Could we maybe see the scene tree?

1 Like

Here are screenshots of all trees

What’s this warning?

1 Like

I set the Player node position to 240,450 when I was trying to figure out what was wrong and that caused the warning because you can’t transform a linked node.

What’s weird is I can get the game to start when I am in the project menu and go directly to run. The player won’t move around the board. But the game is open and the main sprite is there. I have never been able to get the mob to spawn, but I’ve gotten the main player sprite to work as it should with movement and sprite flipping while moving.

Hey, thank you all for your help and replies!

I got it to work. I must have put some code in the wrong node or something. I’m still not sure, exactly. I started over and got it all finished and working, though.

1 Like

Cool. Please mark this thread as solved, if all your problems are fixed now.