Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Your first 2D game" > "Cooding the player" has outdated/incorrect information #7085

Closed
VilcsiTH opened this issue Mar 29, 2023 · 3 comments
Closed
Labels

Comments

@VilcsiTH
Copy link

Your Godot version: 4.0.1.stable.mono.official.cacf49999

Issue description:
This is mainly regarding the C# documentation.

  1. The first warning on the page instructs the user to rebuild assemblies to see new export variables or signals. The Mono button at the bottom of the window no longer reveals a mono panel, so there is no "Rebuild Project" to be found. The current way is to use the Build button in the top right corner of the window.
  2. During the setup of inputs, the tutorial defines a Vector2 object by the name of velocity. We modify components by calling velocity.x and velocity.y, however, the correct usage is velocity.X and velocity.Y, without capitalization the build errors.
  3. (This may be an editor bug or an error of my own, not a documentation error.) After adding the Signal HitEventHandler() and connecting the body_entered(body: Node2D) Signal, the green icon that indicates a connected signal does not appear. A warn does appear, stating Missing connected method '_on_body_entered' for signal 'body_entered' from node 'Player' to node 'Player'. and refusing to build. The new function is added to the very bottom of the script, outside of the player class, resulting in two errors:
    player.cs(79,1): Top-level statements must precede namespace and type declarations.
    player.cs(79,1): The modifier 'private' is not valid for this item
    This can be solved by moving the code inside the player class. The warn does not disappear, however.
  4. It is not clear where the last piece of code, the function Start(Vector2 pos), should go. Considering that the previous step places the Signal function outside of the Player class, logic dictates that it should also go outside of it, however, this adds 2 more errors of the same type as seen above. This can also be resolved by placing the code inside the player class.

URL to the documentation page: https://docs.godotengine.org/en/4.0/getting_started/first_2d_game/03.coding_the_player.html

@VilcsiTH VilcsiTH added the bug label Mar 29, 2023
@MisoMosiSpy
Copy link
Contributor

I am working on PR for this, for the 3rd point it seems like a know long peding issue. godotengine/godot#18721

@raulsntos
Copy link
Member

The first warning on the page instructs the user to rebuild assemblies to see new export variables or signals. The Mono button at the bottom of the window no longer reveals a mono panel, so there is no "Rebuild Project" to be found. The current way is to use the Build button in the top right corner of the window.

This was fixed by #6811. The bottom panel is now named MSBuild. Alternatively, as you found out, you can also use the Build button in the top right corner.

During the setup of inputs, the tutorial defines a Vector2 object by the name of velocity. We modify components by calling velocity.x and velocity.y, however, the correct usage is velocity.X and velocity.Y, without capitalization the build errors.

This was fixed by #6811.

After adding the Signal HitEventHandler() and connecting the body_entered(body: Node2D) Signal, the green icon that indicates a connected signal does not appear.

This is a feature of the Godot code editor, note that the Godot code editor doesn't support C#.

It is recommended to use an external IDE such as VSCode, Visual Studio 2022 or JetBrains Rider. Some extensions for those IDEs may attempt to provide a similar functionality.

A warn does appear, stating Missing connected method '_on_body_entered' for signal 'body_entered' from node 'Player' to node 'Player'. and refusing to build. The new function is added to the very bottom of the script, outside of the player class [...] This can be solved by moving the code inside the player class. The warn does not disappear, however.

As mentioned by @MisoMosiSpy, this is a known bug (godotengine/godot#18721). Keep in mind when connecting a signal to a method, the name you specify must match the name used to define the method in your script (this is also case-sensitive).

It is not clear where the last piece of code, the function Start(Vector2 pos), should go. Considering that the previous step places the Signal function outside of the Player class, logic dictates that it should also go outside of it

Methods can be defined anywhere inside your class. If you are new to C# you may be interested in the Microsoft documentation and, even if you are not new to C#, you may also be interested in the C# basics documentation page.

@VilcsiTH
Copy link
Author

Methods can be defined anywhere inside your class. If you are new to C# you may be interested in the Microsoft documentation and, even if you are not new to C#, you may also be interested in the C# basics documentation page.

I was using the documentation to get a better understanding of the Godot environment and how it handles code. Signals are a new thing for me, and I wasn't sure if they were meant to be part of the class, or if Godot would handle them in a different way - I wasn't sure if the Start(Vector2 pos) function was still part of the Signal system, or just a normal method to be defined.
Granted, this is more of a personal understanding issue, I understand choosing to disregard it.

Loading the page anew shows my first two points fixed, and due to the third being non-docs related, I'll close this issue. Thank you for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants