2D game tutorial script not working

Godot Version

` 4.2.1

Question

Hey there folks. I’m working my way through the 2D game tutorial to get my bearings working with Godot. Unfortunately, despite following the tutorial best I can, something has gone wrong that I can’t quite find the cause for.
What I’m trying to do: Run the game so that the script attached to the main node runs
What is actually happening: The solution builds, but the script never runs. Or at least the breakpoint I placed on the node.ready function is never reached. As a result, the game screen remains empty

I’ve uploaded my work as a public repo Here

Hope to get answers soon so I can get back into it

1 Like

I went to take a look, but it’s in C# and I don’t use Godot with C#. I would recommend that you upgrade your version of Godot to 4.3 Stable though and try again. Most likely the docs you are following are for 4.3.

1 Like

4.3 doesn’t have C# yet. And I am working in that because it’s what I’m familiar with. I’d have to throw away everything and start over to upgrade

1 Like

is have from beginning. You get misinformed somewhere.

Git don’t like changes in Letter case, is better rename to different name first and later you change back to target name

2 Likes

As @Moreus said, they do have C# for 4.3. I actually specifically hunted down the 4.3 archive link for you and linked that in my post above. In fact, 4.4.dev1 is out now, but if you’re learning, I suggest staying with a Stable version.

Also, I’m not sure what your reason for using C# is, but as a developer who has used many languages professionally (including C#), I will say that GDScipt is a much more forgiving language for using Godot, and you don’t lose any power using it. So far, I haven’t found any limitations of using it, and there are a lot more examples and help with GDScript.

Having said that, if you want to use C#, check out Mina Pêcheux on YouTube. She has great tutorial books as well. All her tutorials are written in C#, and come with links on GitHub.

1 Like

I will consider the usr of gdscript. I have been using C# because it’s what I learned and I didn’t want to add the load of a new language on top of understanding Godot’s scene-based logic while doing the tutorial.

As for right now though, I would politely request to stay on topic, which is the problem I have been having getting the code to Run.

Update on that matter too:
After some wiggling and deleting the imports file, the program has settled on an error message that it can’t find and instantiate the player script. I have renamed the script outside of the editor in file explorer, in the references of the node’s file and in tge godot editir using the rename function but the old name of the script is still floating around somewhere and refusing to be changed.

1 Like

You don’t read my message till end. Git don’t change of letters cases. In Godot you needed check if all noddes have scripts now and after this make new repo or wipe previous

Uh. I’m sorry, can you post that as a step by step? I can’t quite parse what you mean due to language barrier

obraz

obraz

I don’t know why you change nice upper case to lower case and git don’t care about but Godot does.

You use git to go back to working version of your project. if your Project save project as new branch. if its break and you cannot fix or fix is to time expensive you back to working branch.

Don’t be afraid to start over tutorial you will see how many you remember from scrach.

The editor keeps doing that against my will. Every time I rebuild the solution it changes all the filenames back the wrong way around. And there never was a working version of the project. The first version I only pushed to git so I could share a non-functional version

1 Like

I just found out C# scripts don’t even support breakpoints. I’m starting over in gdscript


Hi @cygn_0, C# code advocate here! :raised_hands:

Simple fix to get your solution up and running!

I downloaded your project, I imported in Godot 4.2.2 .NET (just for compatibility of the project).

Then, as others have mentioned, the script attached to the first node (root) is not the same (just move your mouse over the script icon).

How to solve?

Just right click and detach the current one (player.cs):

Drag and drop the correct C# script (Player.cs):

Save the scene (player.tscn) with the new C# script attached.

Repeat the same process for the “main.tscn” scene (to use Main.cs) and save the scene.

Then set the main.tscn as the Main Scene, just right click over the main.tscn and set:

Now, you can build and run the C# application :sunglasses:

And you can play by moving with the arrow keys on your keyboard:

I hope it helps you to continue your learning! :slight_smile:

1 Like

As Aforementioned. I started over with the GDscript tutorial. That revealed to me that at the least I hadn’t set the root node correctly as you mentioned. Marking this as the solution since it’s a comprehensive step by step of how to fix this. Thanks for the effort in any case :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.