Create Your First Godot 4 Game
Lesson 6: Creating a collectible
Video Notes
Let’s give our raptor some treats! In this lesson, we’ll cover creating a collectible bug that our dino can grab to score some points.
The final code can be found here: https://github.com/quiver-dev/raptor-run.
Corrections
In Godot 4 Beta 16 or higher, the AnimatedSprite2D’s Playing checkbox has been removed from the Inspector. It has been replaced by the Autoplay button, which can be found in SpriteFrames panel next to the trashcan icon.
Improvements
With newer versions of Godot 4, you can simplify the platform selection with the following:
var random_platform = available_platforms.pick_random()
-
strawfervor
Dec. 15, 2022 at 9:31 p.m.This could be very nice tutorial, but it’s way too fast. It is impossible to follow you in this course, because you are pasting things, so it’s very frustraiting to stop or rewind it all the times to catch you up. In this lesson you forgot to mention about line of code with collect_sound varible (9 minute).
-
amit
Dec. 16, 2022 at 7:01 p.m.Thanks for the feedback. It’s difficult to find the pacing that suits everyone, but I agree we should avoid copy and pasting multiple lines and that’s something we’ll address in future tutorials. Speaking for myself, I find myself pausing the video even if I can keep up with the writing the code, since it often takes a moment for the idea to process.
I believe the
collect_sound
variable is initialized at 8:30 in the video. Is that what you mean?
-
-
Malcx
Feb. 12, 2023 at 12:31 p.m.Why do we set the label text on every frame rather than just when the score changes?
And would it not be more performant to create the available_platforms array once rather than every spawn call?
-
amit
Feb. 24, 2023 at 7:13 p.m.Both valid points. I think the best way to handle updating the score label would be using a setter function on the
score
variable, which we don’t cover in this tutorial. Andavailable_platforms
could certainly be initialized once.
-
Lessons
- Lesson 1: Getting started with Godot 4
- Lesson 2: Overview of the Godot interface
- Lesson 3: Setting up the level
- Lesson 4: Creating the player
- Lesson 5: Spawning the platforms
- Lesson 6: Creating a collectible
- Lesson 7: Creating an enemy
- Lesson 8: Handling player death
- Lesson 9: Creating the player projectile
- Lesson 10: Adding the final touches
- Lesson 11: Exporting your game and wrapping up
Anoniempje
Nov. 7, 2022 at 7:55 p.m.As of godot 4 beta 4 there is a random pick from array function.
At 15m55s, line 42 and 43 can now be:
amit
Nov. 8, 2022 at 12:14 a.m.Nice find! A small, but welcome addition to GDScript.