Godot Debugging Techniques EVERY Dev Should Know

Ойындар

In this Godot 4 tutorial, learn several debugging tips and techniques that are better than print()ing to the console. Learn about different print/error statements, use the Scene Tree to debug, and get a breakdown of the Godot debugger itself. With these and a few other Godot features you'll go from caveman debugging to hunting down bugs like a veteran gamedev. You can do this ❤️ 💪
0:00 - Intro
0:21 - Print alternatives
2:41 - Remote Scene Tree
3:59 - Always on Top
6:57 - The Debugger
9:51 - Deleting Save Files
11:54 - Stepping Through Code
15:04 - Visual Debugging
15:57 - Outro
#godot4 #debugging #debugger #gdscript #gamedev #gamedevelopment

Пікірлер: 132

  • @BenHunterRolfe
    @BenHunterRolfe2 ай бұрын

    Great tips! I worry that some viewers might not realise that "always on top" affects the behaviour of their final game, though.

  • @baconandgames

    @baconandgames

    2 ай бұрын

    Oh really? I honestly thought that was just an editor setting. 😳 Thank you for letting me know.

  • @AMTunLimited
    @AMTunLimited3 ай бұрын

    Out of all the courses I feel like I should have had in my computer science degree, properly using a debugger really should have been near the top

  • @baconandgames

    @baconandgames

    3 ай бұрын

    You and me both, but it’s never too late to add to your bag of tricks (or mine)! 🤜🤛

  • @whannabi

    @whannabi

    3 ай бұрын

    print("It's working!")

  • @baconandgames

    @baconandgames

    3 ай бұрын

    That would have been a much shorter video 🤣

  • @BinaryBolias

    @BinaryBolias

    2 ай бұрын

    ​@@whannabi if not found_errors: get_tree().quit(ExitCodes.ERROR_NOT_FOUND)

  • @glorytoarstotzka330
    @glorytoarstotzka3303 ай бұрын

    my biggest tip is using *assert(condition: bool, message: str)* for when critical stuff fails because it also stops the game if the condition doesn't fail. I use this primarily when initializing things, or when really unexpected behavior happens. here's an example from my game static func setup_state_machine(node): assert(StateMachine.is_configured_properly(node), "%s doesn't have the necessary variables setup to be compatible with the State Machine" % node) node._states_node = node.get_node("states") assert(node._states_node != null, "%s requires a node called 'states' containing the states for the State Machine to work properly" % node) node._current_state = node._states_node.get_child(0) node._current_state.set_parent(node) node._current_state.on_state_enter() node._current_state.is_active = true node._last_state = node._current_state (I have a class that allows me to an attach a state machine to any object, and here I added 2 asserts to make sure that before the program moves forward, I didn't misconfigure something)

  • @baconandgames

    @baconandgames

    3 ай бұрын

    This is great! I actually had assert in the first cut but I think I chopped it for time (or because it’s going in the follow up to this video, I can’t recall 🤣- have to check my notes). Thank you for sharing this!!!

  • @CraftedQuests
    @CraftedQuests3 ай бұрын

    One thing I found insanely useful is the "misc" tab in the debugger. I made a little game for a game jam, where you interacted alot with interfaces. Lots of small mini games, where you had drag stuff, click stuff, etc And often it happenend that I forgot to put "Mouse ignore" on a gui element. In the misc tab of the debugger, you get the information which element you clicked last :D Saved me so much time! Great video! I immediatly added the "On Top" feature to my project. xD I always drag my window on a different display, and back, different frame rates... it is annoying. The On Top Feature saves me all of that!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    I believe there’s a setting that will also force the game to open on a specific monitor in a multi monitor setup. I feel like someone mentioned that in a comment 🤔 Thanks for watching and saying hello 👋

  • @mission-toast
    @mission-toast3 ай бұрын

    Very useful. Thanks for putting this together!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Thank you for watching 🙏🙏🙏

  • @GreenLightDev
    @GreenLightDev4 ай бұрын

    Exactly what I needed--thank you! 🙏

  • @baconandgames

    @baconandgames

    4 ай бұрын

    Aw thank you! That made my day. ❤️

  • @TheUlf
    @TheUlf3 ай бұрын

    This is so incredibly helpful, thank you!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    You are so incredibly welcome. Thank you ❤️

  • @OctagonalSquare
    @OctagonalSquare3 ай бұрын

    4:44 on a similar note to always on top, if you have a multi monitor setup, you can set it to always launch on a specific screen and keep your editor on the other. Then you’ll have the full editor while still seeing the game

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Oooh, that’s a great tip! Thanks for sharing that ❤️

  • @nahruz.w3044
    @nahruz.w30443 ай бұрын

    I NEED THIS! Thank you for uploading this video

  • @baconandgames

    @baconandgames

    3 ай бұрын

    🥹 Thank you 🙏 that’s really nice to hear. I’m glad you doing it helpful.

  • @parmeshwarrathod105
    @parmeshwarrathod1053 ай бұрын

    Man this was good info, you have saved of time i would have spent knowing debugging in godot editor. thanks mate, subscried.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Thank you, my friend! Looking forward to seeing what you’re working on!

  • @cyborganic
    @cyborganic2 ай бұрын

    Very helpful video! Thank you!

  • @baconandgames

    @baconandgames

    2 ай бұрын

    Thank you so much 🙏❤️

  • @Peter-wl5xm
    @Peter-wl5xm3 ай бұрын

    Thanks for all the options!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    You’re welcome. Thanks for watching!

  • @danielg9446
    @danielg94463 ай бұрын

    It was super informative, ty very much man!!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    You’re welcome very much 🙏

  • @gimpycoder8548
    @gimpycoder85483 ай бұрын

    This suggestion is only useful for functions that you want to step into but don't want to go through every single line every time. If you have a troublesome area that you need to debug with breakpoints, I recommend setting a breakpoint at the start and then another breakpoint after every line that has a called function that you may be interested in stepping into. This way, you can step into functions of interest and then use continue to go back to where you were without losing your place in code-time. Going off your demonstrated example, if pushing left on that particular tile was the problem, hitting continue would advance you past the trouble spot. Doing it this way allows you to easily go back to where you were without advancing time.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Excellent point! 🙌

  • @darenn-keller
    @darenn-keller3 ай бұрын

    Really cool video, those auto remote scene switch and always on top parameters are definitely gonna make my life easier. Thanks!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    🥹 I recently learned there’s a known bug in the Remote SceneTree that can cause more complex games to stutter a bit while open. So if you experience some odd lag, keep that in mind. I still thing auto-open is the way to go but until they fix that, just keep an eye out. I’ve never experienced it myself so I don’t know what it takes to trigger that bug.

  • @darenn-keller

    @darenn-keller

    3 ай бұрын

    @@baconandgames Oh alright I'll be careful then, thanks for the heads up mate!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    @darenn-keller yeah I mean, I’ve never seen it myself so I can’t say how far you have to push Godot before it turns up or how common it is. 🤷‍♂️ Someone in my comments gave me a heads up. Just passing it along! Hope you share your game with us when you’re ready!

  • @corpsinhere
    @corpsinhere3 ай бұрын

    Quality content: subscribed :)!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    ❤️🙏

  • @Gwizz1027
    @Gwizz10273 ай бұрын

    Hey man, great video! After watching, I want to make a video going more in depth into every print function. I'll link this video in the description!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Oh right on! That would be great. Let me know when it’s up and I’ll link back. I follow your channel (though probably from my personal account) Great stuff 🤜🤛

  • @VixenteEs
    @VixenteEs3 ай бұрын

    Nice work. Please keep it up! :)

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Deal! Thanks for watching!

  • @CaioMGA
    @CaioMGA3 ай бұрын

    great video. Thanks for uploading

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Thanks for watching! 🙏 Plenty more coming.

  • @LeGAT45
    @LeGAT452 ай бұрын

    Extremely helpful!!

  • @baconandgames

    @baconandgames

    2 ай бұрын

    Thanks for watching! I appreciate you 🙏

  • @duolc_7
    @duolc_73 ай бұрын

    Nice tips 👌

  • @baconandgames

    @baconandgames

    3 ай бұрын

    🙏

  • @teahands
    @teahands3 ай бұрын

    Three minutes in and auto switch to remote has changed my life. Thank you! p.s. I agree with the other commenter about volume, ended up with my laptop speakers at 100% which isn't ideal. Great video though!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    It’s a revelation, isn’t it? There are so many setting like that in Godot to make your life easier that I’m surprised aren’t on by default (not picking on the good folks working on it). I appreciate the feedback on volume, truly. I can only improve if I get feedback! Thanks for watching 🙏

  • @longuemire748
    @longuemire7482 ай бұрын

    Thank you for this video.

  • @baconandgames

    @baconandgames

    2 ай бұрын

    It’s my pleasure! Thank you for watching 🙏❤️

  • @laoAnGame
    @laoAnGame3 күн бұрын

    Thank you. I'm learning Godot!

  • @baconandgames

    @baconandgames

    3 күн бұрын

    Me too! 😬

  • @Starkandco
    @Starkandco3 ай бұрын

    Debug window to call whatever stuff helps you test is really useful too. I like to have separate windows than my main application too

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Can you provide more info on this? I’m not sure I fully understand but I’d love to know more 🙏

  • @ekagaurangadas
    @ekagaurangadas3 ай бұрын

    I subscribed when you said "cave person", keep up the good work 😂

  • @baconandgames

    @baconandgames

    3 ай бұрын

    And my parents told me being a smartass would get me in trouble. 🤣 Thanks! 🙏

  • @Afreshio
    @Afreshio3 ай бұрын

    you gained a subscriber!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Welcome and thank you! 🙏❤️

  • @DevilBlackDeath
    @DevilBlackDeath3 ай бұрын

    When it comes to visual debugging you can also create your own. When debugging complex systems this can come in handy. I'm programming a complete platforming system and when you want to start debugging some of the more complex movement and jump algorithm, having that stuff on screen at a specific position really helps, especially when you keep track of 5 to 10 different variables.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    That’s super cool! I love this. 👏

  • @DevilBlackDeath

    @DevilBlackDeath

    3 ай бұрын

    @@baconandgames Thanks ! I feel like this is also kind of its own thing. It has cons and pros compared to other methods. It's longer to implement and it means either signalling or finding a good non destructive way to update the UI but it lets you track multiple states and components in real time. I'm glad there's some good debugging resources for Godot because it's probably an area where many beginners will struggle ! Taught me a couple of Godot-specific things too so thanks for that :)

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Hey you know what… that’s making games. Pros and cons to every choice and there’s not always a “right” way. I always appreciate hearing how others approach stuff because it helps me grow too! Thanks for the comments and for watching. I hope you stick around and continue to teach me and others 🤜🤛

  • @DevilBlackDeath

    @DevilBlackDeath

    3 ай бұрын

    @@baconandgames So true ! Well thanks for the video and the tips as well and I'll definitely keep an eye out ;)

  • @baconandgames

    @baconandgames

    3 ай бұрын

    🥹🙏

  • @felipefacundes1
    @felipefacundes12 ай бұрын

    Cool !!! Very save !!!

  • @DEATHTRUTH
    @DEATHTRUTH14 күн бұрын

    What I also found useful was utilising Input.set_mouse_mode to capture and uncapture the mouse when clicking the viewport and pressing esc respectively. This is good for 3d games which use your mouse input directly.

  • @baconandgames

    @baconandgames

    14 күн бұрын

    Oh interesting! Thanks for the tip 🤜🤛

  • @micmacha
    @micmacha3 ай бұрын

    I had no idea about "Always on Top" and "Automatically Switch to Remote". Thank you!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    You’re welcome! Those are game changers for me. It’s wild how many settings there are like that to turn on or off.

  • @alectrem
    @alectrem3 ай бұрын

    Thank you!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    You’re welcome!

  • @anonimowelwiatko4455
    @anonimowelwiatko44553 ай бұрын

    I can't believe you didn't mention assertions. These are very good and quite important blocks to throw in for code you generally expect to work (you design rest of your code as whatever you check with assertion, couldn't happen). Assertion works like permanent breakpoint that activates only when condition is not met. You can see what's inside your objects/tree as well. Agree with push_error, great tool. Built my testing framework around it to instantly be able to move around stack and see what's inside. Great tools for debugging. As for print as it also has it's own use, I can only suggest to try and use it's % syntax, it's easy to include many variables and you can print whatever type you want with %s + str(var).

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Assert is coming in the next video 😉 I had it in this one but cut it for time and because I like how it fits with the next one. You make a good point though. Thanks for watching!

  • @pennyloafers
    @pennyloafers3 ай бұрын

    You should post this in the Godot forums, I think people would have less questions if they understand basic debugging techniques.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    That’s a great idea. I honestly hadn’t considered that 🤦‍♂️🤣 Thank you!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Great suggestion and done! forum.godotengine.org/t/using-the-godot-debugger/49576

  • @3XC4L1B3R
    @3XC4L1B3R3 ай бұрын

    I was writing a function the other day with a monstrous if-else tree. As a joke between me and myself, I put `print("PEBCAK")` into an if branch that should never run. Seeing that output every frame was... humbling.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Haha. Programming is definitely a humbling experience. I love that you’re having some fun with it.

  • @killercrazy21c
    @killercrazy21c3 ай бұрын

    Make validation script tool could be great too, since we can have tooltip and icon on the editor if I remember well. Silly mistake of initialisation are more friendly that way.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    That’s a neat idea! 🙏

  • @ryanze26
    @ryanze263 ай бұрын

    thank you!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    🤜🤛

  • @darthnegativehunter8659
    @darthnegativehunter86593 ай бұрын

    very helpful.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Glad it was helpful!

  • @texcolorado9550
    @texcolorado95503 ай бұрын

    thanks a lot :)

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Happy to help. Thanks for watching!

  • @AkaiKnight
    @AkaiKnight4 күн бұрын

    *sees "Always On Top option* oh my goooooooooooood

  • @baconandgames

    @baconandgames

    4 күн бұрын

    Just keep in mind this setting affects the final product. So if you only want this during development (how I use it) make sure you turn it off before the final export.

  • @luisces
    @luisces3 ай бұрын

    One thing I'd like to learn is a more efficient way to debug when using network code. I find it hard as to not even touch break points on my online scenes.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    You and me both! I haven’t found a great way to simulate network lag locally either. I found one decent bit of code for that on GitHub but I was hoping there’s a built in feature for this that I just haven’t found yet. I wish I had resources for you on that but I’ll keep my eyes open. Let me know if you crack it. 💪

  • @noiJadisCailleach
    @noiJadisCailleach3 ай бұрын

    Btw, if anything, just to address what the others are saying, i played the vid at 45% volume. At that level, it's quaint for me. Though in contrast, i think this is just a by-product of volume mgmt of most big youtubers in general. Most are quite loud so i play vids at around 12-25% most times. If we use Linus Tech Tips as a benchmark to compare against - To get both vids to feel to be at the same audio level, in my speakers: random LTT vid: 15 this vid: 45 Tested this over and over, calibrating the volume until i get a matching feel. Hope this helps!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    This is super helpful, thank you! I will look more closely at volume for this week’s video. 🙏

  • @shoggoth
    @shoggoth3 ай бұрын

    How are you defining them globals in the node? Any chance I could take a look at the source for that bit?

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Truth be told, this is from a project of mine that’s a bit of a mess. I was just using it to have something to show debugging. But if you give me more detail I’ll be happy to help you out. Which nodes and which globals? I’d be happy to just send you my autoload files, if that would answer your question

  • @shoggoth

    @shoggoth

    3 ай бұрын

    @@baconandgames I have the autoload defined and it's a subclass of Node but I'm not sure how you're able to alter the exported vars from the inspector (the push strength in your game, for example). I've tried adding a Node to the scene and the global script to the node but that didn't work. I'm a noob, possibly missing something obvious. Thanks for the reply!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    I'm not using any export vars in my autoloads, but that sounds like what you're talking about. Have a look at this page from Godot's docs. docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_exports.html If you're talking about how I edited the strength value in the property inspector, I cover that in the video under Remote Scene Tree. So if export vars isn't what you're after, maybe have a closer look at that section. Hope that helps!

  • @shoggoth

    @shoggoth

    3 ай бұрын

    I rewatched the bit about the remote scene tree, I understand now. Thanks a lot for your help!@@baconandgames

  • @TheBugB
    @TheBugB4 ай бұрын

    Oh yeah I really love cave person debugging cause I’m from 1500 BCE

  • @baconandgames

    @baconandgames

    4 ай бұрын

    🤣

  • @BinaryBolias
    @BinaryBolias2 ай бұрын

    *Good:* _Debugging technique explanation & demonstration._ *Bad:* _Using _*_string_*_ instead of _*_enum_*_ for those "gateway" export variables._ 😱😱😱

  • @baconandgames

    @baconandgames

    2 ай бұрын

    Haha. It’s true. I’m still a little shaky on using enums the way I want in Godot. In fairness, a room could have 50 doors and never repeat a name, like “to-dungeon” or whatever. So I left it flexible but less stable, for sure. If every room only had 1 of 4 doors, like in Zelda, enums make a lot more sense.

  • @baconandgames

    @baconandgames

    2 ай бұрын

    In all honesty, were this not just a sample project I’d problem not use enums either. I’d just store a reference to resource that needs to be loaded. No need for that intermediary translation. But yes, in general, hardcoded strings are often a big no-no. I agree 😉

  • @kishirisu1268
    @kishirisu12683 ай бұрын

    And now use your brakpoints to catch whong character speed during gameplay. Oh, we use print again, but into debug widget. But it is probably too advanced approach LOL

  • @baconandgames

    @baconandgames

    3 ай бұрын

    I saw whatever catches the bugs is fine by me 🐛🧲 😬

  • @lizardrain
    @lizardrain3 ай бұрын

    Just a warning for anyone using "Auto Switch to Remote Scene Tree", having the Remote Scene Tree open can make your game stutter constantly as it's refreshing itself. It was extremely difficult for me to figure out where these stutters were coming from. This issue still hasn't been fixed.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Oh that’s good to know. I’ve never experienced that but I tend to make smaller scale 2D games, so that tracks. I assume those had been logged as a big, yeah? Thanks for mentioning this!

  • @ShiloBuff
    @ShiloBuff3 ай бұрын

    Professional developer here who has programmed for decades. I'm ashamed that I still use print() more often than debugger tools. Maybe this will help push me to break the habit. Thanks.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    Don’t be ashamed, I do too! Think of it like anything else, sometimes a hammer is just fine, but it’s nice to know you have a flamethrower when you need it 🤣 The right tool, for the right job 🤜🤛

  • @kishirisu1268

    @kishirisu1268

    3 ай бұрын

    Person with 1 yr experience - using print for everything. person with 2 yr experience, finally learned debug tools. person with 10 yr - just uses print and get job done.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    @kishirisu1268 took me way longer to do anything but print. 🤜🤛❤️

  • @akaitsuki6466
    @akaitsuki64665 күн бұрын

    What exactly does having the remote scene tree activated do? The only thing I get is that the program freezes when I run it

  • @baconandgames

    @baconandgames

    5 күн бұрын

    Are you making a 3D game? I know that having the remote scene tree open can slow larger project down and cause issues. But the purpose, for games that can handle it, is to have access to the properties of game objects in real time so you can inspect them live. Otherwise you’re just looking at the author time settings, which serves no purpose during testing. I tend to make games that aren’t heavy, so I’ve never run into issues with auto-loading the remote tree. If you’re having issues with that, I’d avoid auto opening it and instead only switch to it when needed.

  • @akaitsuki6466

    @akaitsuki6466

    5 күн бұрын

    @@baconandgames It is a 3D game with a procedural dungeon, I suppose that being so big it is heavier

  • @baconandgames

    @baconandgames

    5 күн бұрын

    Yeah. You’re probably hitting the performance issue. You might still be able to use it, but I wouldn’t set it to auto-switch to the remote tree for your game

  • @1gengabe
    @1gengabe3 ай бұрын

    if the setup takes longer than setting up a print statement then no I am not saving time Edit: oh wow it is as fast and it does save time

  • @baconandgames

    @baconandgames

    3 ай бұрын

    👏👏👏

  • @phoenixweiss
    @phoenixweiss3 ай бұрын

    Thanks a lot! P.S. the recording is very quiet, it’s hard to hear

  • @baconandgames

    @baconandgames

    3 ай бұрын

    I hadn't noticed that. Thanks, I'll take a look and be sure to make any necessary adjustments in future videos. May I ask... have you found this to be the case with any of my other videos or just this one?

  • @phoenixweiss

    @phoenixweiss

    3 ай бұрын

    @@baconandgames Unfortunately, I came across this video through KZread recommendations, and had not watched the other videos before, but since you asked, I had to watch a couple of them. On the one hand, you just have such a calm way of speaking, so partly it might seem that it’s quiet, but on the other hand, it objectively feels like the video about the Scene Manager (a very useful one!) that came out a month ago is a little louder. I understand that this is my IMHO, but it seems to me that if you speak a little louder, it will be a little better. BTW, I like the content itself and the way it is presented, do more!

  • @baconandgames

    @baconandgames

    3 ай бұрын

    @phoenixweiss This is really helpful feedback. I appreciate your bringing it up! 🙏 I’m still learning something new every day about editing videos and KZread in general so every bit of feedback makes a big difference. Better every day, right? Thank you for watching and sharing your thoughts! ❤️🤜🤛

  • @noiJadisCailleach
    @noiJadisCailleach3 ай бұрын

    10 years of software engineering. And i finally learned what that damned red dot that's present in a lot of IDE does! SMH.

  • @baconandgames

    @baconandgames

    3 ай бұрын

    🤣 Well… you still learned it sooner than I did. Thanks for watching 🙏

  • @trepals
    @trepals3 ай бұрын

    Why is KZread attacking me for no reason with this video

  • @baconandgames

    @baconandgames

    3 ай бұрын

    I paid them a LOT of money to target you specifically . So you better watch it, for my sake. Please. I’m begging you. 😅

  • @question_mark
    @question_mark3 ай бұрын

    cave person 💀

  • @baconandgames

    @baconandgames

    3 ай бұрын

    🙈

Келесі