- Edited
Overview
I've been working on a general-purpose debug console for use in a wide variety of projects that anyone can use for free in the Godot Engine. It will be released under the permissive M.I.T license and coded in GDScript.
I'm sure most of you are familiar with what a debug console is and what its purpose is, but in case you don't know, it's a tool used by developers to test/monitor for bugs while in-game. Usually, debug consoles do many things and give the developers a lot of power to test and look for bugs without needing to exit the game and go back into the editor. They usually have many commands that will alter game settings and display useful information about the game. Think of it as a Swiss Army knife.
Famous examples include the debug screen in Minecraft when you press "F3", or in games like Skyrim when you press the "~" tilde key and the debug console appears. A debug console can be useful even for the player.
Needless to say, this type of tool can be invaluable in a game, particularly in larger-scale projects. It's also something that most people don't think of when they're developing a game or don't want to go to the trouble of creating and implementing. So hopefully this project of mine will help solve that for most people. I've designed it to work in any type of game whether it be 2D, 3D, or a mix of both, this will work just fine regardless. There's also no need to reprogram your existing projects to include this, it just works and integrates out of the box.
It's a single scene and single script, all you need to do is to autoload the scene and set it to the top of your load order. After that, it will work and be present in every scene of your game automatically. It's lightweight and uses very few resources.
Usage
The console is opened by pressing the "debug" action which you must create in your project by adding it to your input map in order to use the console, this will bring up the debug console, the game will be paused, and you'll be able to enter commands.
Commands are entered in a prefix-command order. That is, first you type the prefix, followed by a space, followed by the command/value. Then you press the enter/return key to input the command. If the command is valid it will act upon it, if not it will ignore it, or tell you what's wrong with it. Either way, it prints what you just typed into the output log.
Example: cr 500,500
The above example will change the game window to be 500x500 pixels. In the above example "cr" is the prefix and "500,500" is the value ("cr" is short for "change resolution").
#Preview <iframe width="560" height="315" src="https://www.youtube.com/embed/8-I-5UJ26MA" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
This video is already outdated because I've added two more commands since I made it, those being quit
and fov
. The quit
command will close the application, useful in case it gets stuck and you're in fullscreen mode. While fov
will allow you to change the field of view in a 3D scene on the fly. It will automatically check if you have a 3D camera in your current scene to set the fov of, if not, it will tell you so and ignore the command.
As you saw in the video, the console also includes two optional variables exported to the inspector. One that enables the console in-game, and another that sets the mouse visibility when the console is exited. I figured both of these would be useful settings to have available.
This is all the stuff I've managed to do in the last four days since I started this project, but I intend to improve it wherever possible.