Make C++ Games using Godot!!
HTML-код
- Опубликовано: 18 сен 2024
- Wishlist "A Beaver's Tale" now!
store.steampow...
Edit: I COMPLETELY forgot to explain why I use VisualStudio and not VSC. It's because the debugger is about 100 times faster. In VSC (on Windows at least) the debugger is barely usable.
Get notified when our game goes on Steam!!
www.michaeljar...
Play A Beaver's Tale now on itch:
michaeljared.i...
Useful code snippets:
VISUAL STUDIO LAUNCH CONFIG
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "C:\\Godot\\Godot_v4.2.1-stable_win64.exe",
"name": "Godot Game",
"args": [ "--path", "C:\\Godot\\GDExtensionDev\\extension_test2\\a_beavers_tale_cpp2\\demo" ]
},
{
"type": "default",
"project": "C:\\Godot\\Godot_v4.2.1-stable_win64.exe",
"name": "Godot Editor",
"args": [ "C:/Godot/GDExtensionDev/extension_test2/a_beavers_tale_cpp2/demo/project.godot" ]
}
]
}
SCONS
libname = "gdexample"
...
def find_directories(directory):
directories = ["src/"]
for root, dirs, files in os.walk(directory):
directories.extend(["src/" + os.path.relpath(os.path.join(root, d), directory).replace("\\", "/") + "/" for d in dirs])
return directories
source_dirs = find_directories("C:\\Godot\\GDExtensionDev\\extension_test2\\a_beavers_tale_cpp2\\src")
env.Append(CPPPATH=source_dirs)
...
sources = []
for d in source_dirs:
sources.append(Glob(d + "*.cpp"))
example.gdextension
web = "res://bin/web/libgdexample.web.template_debug.wasm32.wasm"
Other useful stuff:
docs.godotengi...
Another game made with GDextension: github.com/kiw...
Fantastic terrain plugin made with GDextension:
terrain3d.read...
"Finally, more C++ tutorials, please. Currently, you are the only source of truth for Godot and C++.
Yes people needs more C++ Godot! =)
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!!
Very well put together. Just the right amount of depth to give a good overview of this development workflow. Subbed!
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.
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!
Sublime!
Amazing video!
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.
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)
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 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
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
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
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
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)"
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.
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
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)