Godot - bad habits you should break

Share

Summary

This video discusses several common bad habits that Godot developers, especially new ones, often fall into and provides better alternatives. The topics range from improper node referencing and over-optimization to neglecting fundamental programming patterns and not using version control.

Highlights

Avoiding Reverse Path Node Referencing
00:00:00

The first bad habit is getting parent nodes or nodes with a reverse path, which can cause crashes and make debugging difficult. Instead, use an exported variable to assign references in the editor, making the code more modular and less prone to errors when reorganizing the scene tree.

Preventing Frequent Node Access
00:02:02

Accessing nodes every single frame using the '$' sign is inefficient, especially when updating properties frequently. A better approach is to store a reference to the node with an 'onready' variable at the start of the game, reducing repeated 'get_node' calls.

Don't Over-Optimize Prematurely
00:03:35

Over-optimizing systems from the beginning, especially for features not yet certain to be in the final game, is a common pitfall. The advice is to get features working first, as long as the code remains modular, and only optimize when performance becomes a real issue. Finishing a playable game is more important than perfect optimization of a single component.

Enhancing Tutorials for Better Learning
00:04:45

Simply watching Godot tutorials without actively engaging or enhancing them can hinder learning. Viewers are encouraged to add new features or modify tutorial projects to solidify their understanding. If unable to enhance, re-watching or referring to Godot documentation is recommended.

Embracing Game Programming Patterns
00:05:31

Neglecting popular game programming patterns like state machines is a significant mistake. Developers, especially beginners, should set aside time to learn these fundamental patterns, as they are crucial for robust game development. The 'Game Programming Patterns' book is suggested as an excellent resource.

Utilizing Static Typing in GDScript
00:06:31

Not using static typing in GDScript is a bad habit addressed. Static typing helps Godot understand variable and function types, leading to cleaner code, compile-time error detection, and improved autocompletion. Developers are encouraged to explicitly type their variables, arguments, and return values.

Using Resource UIDs Instead of Direct Paths
00:08:53

Using direct file paths for scenes and resources can break code if files are renamed or moved. The suggestion is to use Unique Identifiers (UIDs) obtained by copying them from the file system. UIDs ensure that Godot can always locate resources, even after file system changes.

Implementing Version Control
00:09:59

A crucial habit that many developers neglect is not using version control. Version control systems like Git (with platforms like GitHub or GitLab) store every version of a game, providing essential backups and saving immense stress if data is lost or corrupted. Setting it up is free and highly recommended.

Recently Summarized Articles

Loading...