Godot Docs "Your first 2D game coding your player" questions
I have found a yellow warning but no errors but the sprite would not appear on screen.
All the information can be seen in the above screenshots. Any advice would be greatly appreciated.
- Edited
Carmes The editor is saying the body
parameter that is passed into _on_Player_body_entered
isn't used (yet). It is just a warning and can likely be ignored for now.
A warning like this could mean the programmer has made a mistake; perhaps the intention was to use a variable and they didn't? Or maybe they thought they did but have misspelled something (for example) so should always be checked. If you want to suppress the warning, the editor indicates you can change it to _body
:
func _on_Player_body_entered(_body):
pass
And the warning will disappear. But it's likely you'll use it in the tutorial so don't worry too much if you understand why the warning has appeared.
Note: you have a pass
statement here that should also likely be removed before the statements following it (emit_signal
, etc). This probably won't fix the sprite issue (possibly something else, worth reviewing the manual again...) but itโs unnecessary.
Keep going!
I have just figured out, why I could not see the sprite, I however still cannot make the character move.
The full script is seen below, thank you for your aid.
I have hypothesized that the reason I am unable to move sprite is because there is no back round to move it in. I will keep going and come back to that problem later.
Could you try to move the following block up ?
if velocity.length() > 0:
velocity = velocity.normalized() * speed
$AnimatedSprite.play()
else:
$AnimatedSprite.stop()
Put it just before you are beginning to set the position
(before line 25 in your screenshot).
If velocity.x
(or y) is set to 1, then moving the sprite's position by velocity * delta
will move the sprite at the velocity of 1 pixel-per-second.
You have to set a higher value if you want to see anything moving on the screen.
In this tutorial, you need to multiply your velocity vector by the speed value before applying it to the position.
Hello Again I am currently working on the main script for the first 2d game on the official Godot site: https://docs.godotengine.org/en/3.5/getting_started/first_2d_game/05.the_main_game_scene.html
The instructions were unclear, I was instructed to create the code seen in the screenshot below. The instructions could be interpreted in two ways: input the code into the "Player" Script or the "Main" Script. I am not sure where to place this code, thank you for your time and consideration and thank you for being a awesome community.
Another error has shown up that I still have not gotten figured out by manipulating indents or spelling. The error can be seen below.
The source for the instructions I am using is here: https://docs.godotengine.org/en/stable/getting_started/first_2d_game/05.the_main_game_scene.html
- Edited
Tomcat Typing code by hand is much more useful.
Yes. An analogy is trying to learn how to cook by watching videos, but never actually using kitchen utensils and a stove.