Why does my code not work even when I'm following the tutorials exactly?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By EccleSoul

When I am working in GDScript and following a tutorial, the result I get is often different then what I see in the tutorials. I try to make sure the tutorial I’m following is as up-to-date as possible, so the problem isn’t that. Even when I’m following the documentation (yes, I switch to the latest/stable version of it) it comes out different. Is there some kind of bug I’m not aware of?

For clarity, I use GDScript. I gave up on trying to use C#.

Its very difficult to answer this without knowing more details, how does your project differ?

Gluon | 2022-03-20 11:20

Make sure to use Godot docs ‘stable’, since ‘latest’ is for developers and testers making the new versions of Godot.

haydenv | 2022-03-20 16:10

That’s just it. I don’t know. It says “use this code and it will act like it’s supposed to”, but when I do- CODE 4 CODE- it acts completely different. Like when the player character is supposed to bounce off an enemy and it doesn’t even though the code is written like it was supposed to. And yes, I do check for typos.

EccleSoul | 2022-03-20 16:31

I used “stable” and the problem still occured.

EccleSoul | 2022-03-20 16:32

Yes, I too know what it’s like to be baffled as to why my code isn’t working like it’s supposed to.

One thing I noticed is that if I’m following a tutorial and I miss a step somewhere (or I do a step a little bit wrong), sometimes that throws the code off. So if I’m doing a long tutorial, and if my code isn’t working, then I get suspicious that maybe I missed a step in the editor, so I’ll retrace the steps.

If I’m following a short code snippet as a tutorial, then sometimes the tutorial doesn’t explain how the code snippet is supposed to be used. If you are following a code snippet tutorial then if you share a link to it, and share a bit more about your code, then someone might be able to make a guess about what is wrong.

Finally, if I’m following a long tutorial (like the ones in the docs, or a 30 min video tutorial), then if worst comes to worst I’ll just start a fresh project and go through it again to make sure I didn’t make any wrong steps. If after doing that it still doesn’t work, then I get suspicious about the tutorial itself.

haydenv | 2022-03-20 16:53

Unfortunately, I gave up on trying to figure it out. I apologize for not being clear enough. I was following the GDQuest 2D Platformer tutorial (expanded course). The player is supposed to bounce off the enemy and the enemy asset is destroyed. Unfortunately, I gave up and I deleted the project. So I can’t share the code. I’m starting to think the engine is the problem.

EccleSoul | 2022-03-20 17:54

It’s like, I type it like the documentation/tutorial says, but the editor says I have a problem. I then try to add code to get rid of it, but that only creates more problems for me. I feel like just giving up on this engine.

EccleSoul | 2022-04-15 20:15

Sorry for not being clear.

EccleSoul | 2022-04-15 20:16

:bust_in_silhouette: Reply From: Bloogenix

Without going into the specifics of what you’re referring to, an answer for your question is impossible - beyond just saying that you probably missed something you might not know was important.

The problem probably lies in your script’s letter casing
Are you typing it exactly as the tutorial is showing you?
func, for example, is completely different from Func
One is the syntax to start a function, while the other is a variable name. (A poor one)

Gdscript can store and turn basically anything into a var, and the program has absolutely no way of knowing, if you accidently made var with a name similar to something you shouldn’t have — like with Func

Sorry for taking so long. What I mean is that the script editor shows errors when there aren’t supposed to be any. I type it like the documentation/tutorial says and it says I have a problem. I then try to add code to get rid of it, but that only creates more problems for me. I feel like just giving up on this engine.

EccleSoul | 2022-04-15 20:14

:bust_in_silhouette: Reply From: LordViperion

You don’t have to follow tutorials and copy them because you won’t learn much with that.

If you want to learn to code in gdsceipt then download some good beginner python book and practice a lot, write simple console applications.

for example: Prime number checker, display of even and odd numbers using a single loop, friend number finder, and so on.

:bust_in_silhouette: Reply From: ponponyaya

I don’t know what is your problem exactly. But here have some tips:

If you have no idea about programming, maybe you can try CS50x.

If you just can’t follow the tutorial in Godot docs, maybe you can try other step by step video tutorials, for example v1, v2. I think both of them is easy follow for beginner. And here are also lots great video tutorials, you can pick and try to learn.

By the way, if you are unfamiliar with Godot, sometimes the problems may occur in your operation, for example maybe you loss some settings of inspector. So you have to make sure all steps is ok, not just have the same codes with tutorials.

Finially, try to use print statement to test your codes and read error message that Godot give you.

I type it like the documentation/tutorial says and it says I have a problem. I then try to add code to get rid of it, but that only creates more problems for me. I feel like just giving up on this engine. That’s what I meant. Sorry for not being clear.

EccleSoul | 2022-04-15 20:14