Our player has been set up, and it moves around the map when we run the game. There is one problem though, and that is that it moves around statica...
For further actions, you may consider blocking this person and/or reporting abuse
Thank you for this great tutorial Christine - it’s very well organized and detailed… very much appreciated by this beginner!
I am having an issue (perhaps) after completing lesson 4 (animating the player). Everything runs fine, but I do get a message in the debugger anytime two direction keys are held or pressed at the same time (so moving diagonally) - it repeats the error message that in the player_animations() function there is no animation named walk (it references line 49 from your finished code). As I said, it doesn’t appear to impact functionality (although perhaps it may be and I’m not yet aware) but I wonder if I’ve missed something and what I might do to troubleshoot and eliminate the error.
Thank you
J
Hey there! Yes, don't worry about this issue as it doens't break the game - but if it bothers you I do have a fix for you :)
In your player_animations() function, you create an animation name like this:
The returned_direction(new_direction) function can return "up", "down", "side", or "" - but never "walk". It seems the latter case "walk_" is causing the error, because there's no animation direction defined with that name. This causes the returned_direction(new_direction) function to return an empty string, which causes "walk_" to be passed into the play function. This happens when the direction is not perfectly up, down, left, or right (when you're pressing two buttons together).
To fix this, we can set replace our "" with a direction instead in our returned_direction() function. Do this:
Now when you press two buttons together, your side animation should always play and the walk error should be fixed. If you don't want the side animation to always play, you could always return "walk".
Which will loop your walk animation if you press two inputs. To stop it from looping even after you've released your inputs, you can add this code to your physics_process() function:
Using any of the two fixes above should resolve your error. Give it a try, and let me know if it works. Happy coding! 😊
Thanks for the quick reply Christine - very much appreciated!
I tried the first of the two solutions you recommended and it seems to work like a charm - the debugger has stopped spitting out errors :)
I plan on continuing through the tutorial (planning on paying for the PDF guide as well). Looking forward to the journey and any future content/support you provide!
Best
J
I'm glad it worked for you. Have a happy week of coding ahead! 😁
Welcome to the community ☺️. Hope you are having a great time.
Thanks for welcoming people John. 😅
Welcome to the community. Hope you get to enjoy being here.
I followed ( I think!) the guide and when I added the default "side" option at the end of func returned_direction I noticed that if I moved left, then pressed up or down + right, the flip_h value was still set to left causing me to moonwalk.
I did the below and no more moonwalking
Thank you for this, really helpful and detailed.
I love that this isn't skin deep.
Correction:
attack_up animation has 6 frames not 8
Thanks for all of your suggestions Paul! I'll amend it. 😊
Hi Christine! Thanks for the tutorial...I learn by building complete projects vs small tutorials, so I was excited when I came across this series.
I ran into an error when adding "func _input(event)". It said that new_direction was not defined...and it certainly is not defined in the scope of this function. I took a look at your script and saw that you had it defined at the top of the script, but there is no mention of that in the tutorial itself. It may confuse those who are just following along and may not know much about programming yet. Just an FYI!
Aka me. lmao im yelling IT IS DEFINED IM LOOKING RIGHT AT IT! xD
Thank you for this! You resolved my issue!
It appears the creation of these variables from the final code are missing from the steps above:
Insanely confusing. If you're going to post screenshots with minor changes in code, then at the end you should have a single screenshot with the final product. Otherwise junior game devs are going to be playing "where's waldo" looking for flaws in their code BEFORE they have any real concrete understanding of how to find those flaws, or what they even mean.