Thanks a lot for sharing your experience with C++ in Godot! I'm currently learning GDScript. But I have used C++ in the past, so it's a topic I'm also interested in for computationally intensive calculations within the Godot context. Your introduction to this topic is certainly very helpful to me 😊
I might not go that far :) Godot is a very capable 3D engine (although people generally don't know this) but it is nowhere near as heavy, or feature rich as UE. Luckily, there are lots of awesome add-ons (e.g. Terrain3D) to complement it.
I haven't done benchmarking, but it's going to be significant, assuming you use the same node inheritance and logic. The code is ran natively on whatever machine it's running on rather than through the GDscript interpreter first.
100% depends. Especially C++ vs C#. You can write something in C++ thatll be difficult to match in C#, and vice-versa. This is why people tell you to just pick up a language and stick with it. You have to be a good C++ programmer to write something performant in C++, this is not quite the same in stuff like C# or GDScript; the only advantage C++ gives you is being closer to the hardware which is a double-edged sword (you can very easily write something in C++ that is half as fast as C# code if you are not skilled)
@@aversiac-2 yep,having closer access to low level programming stuff is the idea.. but I think there is a lot of performance losst by using GDScript or C# because it needs to bind the C++ functions inside Godot... It's like you written a book in English, but you translate it to Chinese, and then translate it back to English... (There you lost a lot of performance, by using multiple languages)
@@lehisluguer9300 That's not entirely true. The C# is essentially compiled to native code. You could argue that writing your own C++ alongside the native code is inherently more performant. But the thing is, C++ is one of those languages that can vary quite a lot. So it isnt exactly like youre both "speaking English", more like Godot C++ has its own specific dialect, and you, naturally, will have your own. You need to understand your differences and compensate. This is a major reason why many C++ devs stay away from GDExtension or any codebase written in C++ that is not well documented.
gdextension is a real harsh mistress though lol, two days in i'm still working out how to get around bugs needed to learn pointers and macros to save all the typing.... still have bugs now but 2 days of solid coding for my framework itself.... i had good api knowledge already if that sounds fast, if that sounds slow wow you are a hardcore coder.... for me ths is my first serious cpp, i'm trying to do some fluid simulation thanks for the video, i needed a break
No worries! C++ is tough with the use of pointers and references. Luckily Godot has a relatively straightforward use in their code base (and this includes GDextension), namely, that node references use pointers and that resources use RefCounted so that resource management is just handled under the hood.
At the beginning you mention that there was a reason to use VS rather than VSCode, but I didn't catch the reason if it was mentioned later in the video. What's the issue with VSCode?
Yeah sorry, I wasn't super clear there. It's just extremely slow for debugging in windows, and sometimes it crashes altogether. Stepping through breakpoints is so much better in VS.
How did you get your breakpoints working? Ive got debug symbols = yes, but it keeps saying how symbols have not been loaded. Perhaps a mismatch with the msvc compiler and scons which uses a different one?
Definitely. It's just the platform you specify in the scons build. Then the .GDextension files points to it. When you export your game, the extension module file gets exported with your game. If you scroll towards the end of this video that's exactly what I'm doing with the web build.
@@umen2424 not sure what you mean. If you extend the node class, then register the class in C++, you can just create a new node in the editor of that type.
Yeah it's a banger. But honestly it was just a free music clip in ClipChamp, so I have no idea!! Here is the link: clipchamp.com/content/cc_a3a6ce43f-Clock/
how do i setup the visual studio project? i've added the launch.vs.json to .vs but there's no debugging option Edit: manage to get the godot_debug configuration appear but godot has exited with code 255 (0xff) in an instant Edit: previous problem is solved, though got another error message, can't run project: no main scene defined in the project even though the directory included in args contain both project.godot and the .tscn file Edit: nvm, fixed by setting the .tscn file as main scene in godot
I've got a couple ideas for more C++ vids. I'm going to try to gauge the interest in "roll your own" engines, using vcpkg, cmake, and libs like SDL2, bgfx, etc.
When you say to click "use this template" and later you refer to this as "downloading it", do you mean to use "use this template -> create new repository", "use this template -> open in a codespace", or " Code -> Download ZIP"? I am so immensely lost.
Hitting "use this template" is effectively the same as a fork, except it cleans the git history so it doesn't take as much space (you typically don't care about the repos history for template-like repos)
"Finally, more C++ tutorials, please. Currently, you are the only source of truth for Godot and C++.
Yes people needs more C++ Godot! =)
Very well put together. Just the right amount of depth to give a good overview of this development workflow. Subbed!
Thanks a lot for sharing your experience with C++ in Godot! I'm currently learning GDScript. But I have used C++ in the past, so it's a topic I'm also interested in for computationally intensive calculations within the Godot context. Your introduction to this topic is certainly very helpful to me 😊
You're very welcome!!
Worked great! Thank you for sharing. Wishing for more C++ content in the future. I start today, leaving Unreal Engine behind.
This feels like open source unreal engine with C++ and I am here for it.
I might not go that far :) Godot is a very capable 3D engine (although people generally don't know this) but it is nowhere near as heavy, or feature rich as UE. Luckily, there are lots of awesome add-ons (e.g. Terrain3D) to complement it.
Sublime!
we need more kings like you❤🙌
Dude, I wish there was a stronger form of like button for the amount of pain you have saved me with those tips! Well done!
nice tutorial mate... I'm wondering like, what would be the difference in Performance.. of a game made in C++ vs GDScript ? 🤔
I haven't done benchmarking, but it's going to be significant, assuming you use the same node inheritance and logic. The code is ran natively on whatever machine it's running on rather than through the GDscript interpreter first.
@@michaeljburt It would be an awesome video if you did a benchmark. There is not a single one in the whole youtube that I could find.
100% depends. Especially C++ vs C#. You can write something in C++ thatll be difficult to match in C#, and vice-versa. This is why people tell you to just pick up a language and stick with it. You have to be a good C++ programmer to write something performant in C++, this is not quite the same in stuff like C# or GDScript; the only advantage C++ gives you is being closer to the hardware which is a double-edged sword (you can very easily write something in C++ that is half as fast as C# code if you are not skilled)
@@aversiac-2 yep,having closer access to low level programming stuff is the idea.. but I think there is a lot of performance losst by using GDScript or C# because it needs to bind the C++ functions inside Godot... It's like you written a book in English, but you translate it to Chinese, and then translate it back to English... (There you lost a lot of performance, by using multiple languages)
@@lehisluguer9300 That's not entirely true. The C# is essentially compiled to native code. You could argue that writing your own C++ alongside the native code is inherently more performant. But the thing is, C++ is one of those languages that can vary quite a lot. So it isnt exactly like youre both "speaking English", more like Godot C++ has its own specific dialect, and you, naturally, will have your own. You need to understand your differences and compensate. This is a major reason why many C++ devs stay away from GDExtension or any codebase written in C++ that is not well documented.
i've added the launch.vs.json to .vs but there's no debugging option
gdextension is a real harsh mistress though lol, two days in i'm still working out how to get around bugs needed to learn pointers and macros to save all the typing.... still have bugs now but 2 days of solid coding for my framework itself.... i had good api knowledge already if that sounds fast, if that sounds slow wow you are a hardcore coder.... for me ths is my first serious cpp, i'm trying to do some fluid simulation
thanks for the video, i needed a break
No worries! C++ is tough with the use of pointers and references. Luckily Godot has a relatively straightforward use in their code base (and this includes GDextension), namely, that node references use pointers and that resources use RefCounted so that resource management is just handled under the hood.
At the beginning you mention that there was a reason to use VS rather than VSCode, but I didn't catch the reason if it was mentioned later in the video. What's the issue with VSCode?
Yeah sorry, I wasn't super clear there. It's just extremely slow for debugging in windows, and sometimes it crashes altogether. Stepping through breakpoints is so much better in VS.
vscode is just notepad with extra steps. I use it to write minecraft coordinates and that's about it.
@@puppergump4117 why dont you just use notepad lmao
How did you get your breakpoints working? Ive got debug symbols = yes, but it keeps saying how symbols have not been loaded. Perhaps a mismatch with the msvc compiler and scons which uses a different one?
Just commenting here for posterity - it seems the issue was using the mono version of the engine. You can still build and run, but no breakpoints.
All working great but when setting breakpoints it doesn't stop
Likely it means you aren't building your GDextension with debug symbols
@@michaeljburt scons : -j4 target=template_debug dev_build=yes debug_symbols=yes , the product is gdexample.windows.template_debug.dev.x86_64.dll
Amazing video!
is it possible to target different platforms, e.g mobile using gdextension?
Definitely. It's just the platform you specify in the scons build. Then the .GDextension files points to it. When you export your game, the extension module file gets exported with your game. If you scroll towards the end of this video that's exactly what I'm doing with the web build.
@@michaeljburt how to initialed the extension from the actual game in the editor ? how do you attach the scripts to the game object ?
@@umen2424 not sure what you mean. If you extend the node class, then register the class in C++, you can just create a new node in the editor of that type.
What about making a paid/free course on how to make a simple game using c++ in godot?
That would be a good one to do. If I ever get time I'll consider it :) a little bit too busy these days
What’s your intro music? It sounds sick😮
Yeah it's a banger. But honestly it was just a free music clip in ClipChamp, so I have no idea!! Here is the link:
clipchamp.com/content/cc_a3a6ce43f-Clock/
Maybe search "Clock (Intro)"
how do i setup the visual studio project? i've added the launch.vs.json to .vs but there's no debugging option
Edit: manage to get the godot_debug configuration appear but godot has exited with code 255 (0xff) in an instant
Edit: previous problem is solved, though got another error message, can't run project: no main scene defined in the project even though the directory included in args contain both project.godot and the .tscn file
Edit: nvm, fixed by setting the .tscn file as main scene in godot
Sounds like you figured it out! Happy hunting.
how did you fix godot exiting with code 255?
i think it have something to do with missing main scene, make sure that you have a scene selected as main scene or you have a scene at all
@@mixer2.0
@@valden2217 I have.
@@mixer2.0 sorry i don't know the fix for your problem. I suggest you try to find the solution in stack exchange/godot forum or using AI like gpt
uff c++ and unreal is hard to find, but how did i manage to be here?
Godot is calling for you!!
can you do this other than visual studio like linux vim or any other linux ide
You can, you just won't get debugging
@@michaeljburt srry if im asking but what about VsCode ?
@@JebaliJihed-g5c Even in unreal engine, you either use Rider or Visual Studio if you're serious about C++ pretty much
Godot opens projects manager instead of project itself. And after choosing project debugger detaches. Why is that?
Hmm, early in the video I go through both options. It really depends on what argument you launch the engine with
@@michaeljburt I have everything setup as you have. When I launch Godot game config, godot instantly exits with code 255
Nice!!! 👉More C++ tutorials👈
I've got a couple ideas for more C++ vids. I'm going to try to gauge the interest in "roll your own" engines, using vcpkg, cmake, and libs like SDL2, bgfx, etc.
When you say to click "use this template" and later you refer to this as "downloading it", do you mean to use "use this template -> create new repository", "use this template -> open in a codespace", or " Code -> Download ZIP"? I am so immensely lost.
Hitting "use this template" is effectively the same as a fork, except it cleans the git history so it doesn't take as much space (you typically don't care about the repos history for template-like repos)