Start Your Game Creation Journey Today! (Godot beginner tutorial)
Summary
TLDRThis tutorial guides beginners through creating a 2D platformer game using the free, open-source Godot engine. It covers installing Godot, setting up a new project, and designing a scene with a background, ground, and character. The script teaches adding animations, basic movement controls, and refining player interactions. By the end, viewers will have built a functional game and learned foundational game development concepts.
Takeaways
- 🚀 **Start with Basics**: When learning a new game engine, begin with creating a simple platformer game to understand the fundamentals.
- 🌐 **Choose an Engine**: Use Godot, a free and open-source engine, for creating your first game project.
- 📂 **Project Structure**: Organize your projects by creating a new directory for each new project within Godot.
- 🎨 **Scene Creation**: A scene in Godot acts as a container for all game components, both static and dynamic.
- 🖼️ **Background Setup**: Use texture rectangles to create backgrounds and adjust their properties to fit the game window.
- 🧱 **Ground Creation**: Utilize tile maps for creating ground and other scene objects, allowing for easy painting of tiles.
- 🐸 **Character Setup**: Create a character with a sprite for visuals and a collision shape for physics interactions.
- 🔗 **Subscene Utility**: Save branches of the scene as subscenes to facilitate reusability and organized editing.
- ▶️ **Game Testing**: Regularly test the game to check for collisions, character movements, and overall gameplay.
- 💻 **Scripting Movement**: Use GScript to add movement control to the character, making use of built-in templates for character movement.
- 🔄 **Input Mapping**: Define custom key mappings for character control in the project settings for a more tailored input experience.
Q & A
What is the recommended game engine for beginners according to the script?
-The recommended game engine for beginners is Godot, a free and open-source engine that allows you to create your first dream project.
What is the first step in creating a new project in Godot?
-The first step in creating a new project in Godot is to visit the official website, download the latest version of the Godot engine, and then create a new directory to hold all future Godot projects.
How do you create a new scene in Godot?
-To create a new scene in Godot, you go to the top left, click on 'Other Node', select 'Node' from the 'Scene' window, and click 'Create'. This will be the root of the scene, and all other components will be children of it.
What is the purpose of saving the scene with a specific file extension in Godot?
-Saving the scene with the '.dscn' file extension in Godot is to ensure that the scene format is recognized by the engine and can be easily located and accessed within the project's file structure.
How do you import a background image into your Godot project?
-To import a background image into your Godot project, you drag the image into the 'FileSystem' section, which makes it a part of the project, and then create a 'TextureRect' node to display the image on the scene.
What is the 'TileMap' node used for in Godot, and how do you configure it?
-The 'TileMap' node in Godot is used for creating grid-based levels. It is configured by creating a new 'TileSet', importing the terrain image, and then drawing the tiles on the scene using the 'TileMap' tab.
How do you create a character in Godot and what are the essential child nodes it should have?
-To create a character in Godot, you create a new 'Node2D' called 'CharacterBody2D', which should have two child nodes: a 'Sprite' node to define its image and a 'CollisionShape2D' node to define what touches the ground and collides with other elements.
What is a subscene in Godot and why is it useful?
-A subscene in Godot is a group of nodes that can be saved as a single entity, also known as a prefab. It is useful for organizing complex entities like characters and for making changes that apply to multiple instances of the same entity.
How do you add movement to a character in Godot using scripting?
-To add movement to a character in Godot, you create a script attached to the character's root node, use the 'GDScript' language, and utilize a built-in template for moving 2D characters. The script checks for ground collision, jump inputs, and horizontal movement inputs to control the character's velocity.
What are the steps to create animations for a character in Godot?
-To create animations for a character in Godot, you change the 'Sprite' node to an 'AnimatedSprite' node, import the animation frames, add them to the 'SpriteFrames' property, and then set the animation to play on load by selecting the animation and enabling 'Play on Load'.
How do you make a character's movement smoother in Godot?
-To make a character's movement smoother in Godot, you can tweak the 'move_and_slide' function parameters such as 'max_speed', 'friction', and 'stop_threshold', and adjust the 'gravity' and 'jump' velocity in the project settings.
How do you customize the input actions for a character in Godot?
-To customize the input actions for a character in Godot, you go to 'Project Settings', select the 'Input Map' tab, declare actions and key mappings, and then replace the UI action strings in the script with the defined actions like 'jump', 'left', and 'right'.
Outlines
🚀 Starting a Platformer Game in Godot
The paragraph introduces the process of starting a platformer game in Godot, a free and open-source game engine. It guides users through the installation of Godot, creating a new project, and setting up the main editor window. The focus is on creating a scene, which is a container for all game components. It explains how to create a basic 2D scene with a background, ground, and character. The paragraph also covers importing assets, setting up a tile map for the ground, and creating a character with a sprite and collider. The process of saving scenes and organizing the project structure is also discussed.
🛠️ Building the Game Environment and Character
This section delves into enhancing the game environment by resizing tiles for better visibility and adjusting texture filters for clarity. It introduces the concept of level design using tile maps, allowing for the creation of complex game levels. The paragraph also covers the creation of the main character, including setting up a sprite and a collision shape. It explains the importance of subscenes for organizing game objects and the process of testing the game to ensure basic functionality. The segment concludes with a brief on adding a script to the character for basic movement.
💻 Scripting for Character Movement
The focus of this paragraph is on scripting the character's movement within the game. It begins with a template script for character control and explains how to set up and configure the script. The paragraph addresses the importance of collision detection between the character and the game environment. It also covers how to implement and test basic movement controls using keyboard inputs. The segment concludes with a discussion on enhancing the character's appearance with an idle animation, which adds a dynamic element to the character's presentation.
🎮 Enhancing Character Animation and Control
This section focuses on refining the character's animations and control mechanisms. It starts with the process of adding animations for different character states, such as jumping and running, using the AnimatedSprite2D node. The paragraph explains how to implement these animations within the script to enhance the character's movement dynamics. It also covers tweaking the character controller's parameters for smoother movement and jumping. The segment concludes with a discussion on optimizing the character's movement response and the impact of these adjustments on gameplay.
🔄 Customizing Input Mappings for Better Control
The final paragraph discusses the customization of input mappings for the game. It explains how to define actions and key mappings in the project settings, allowing for a more tailored control scheme. The paragraph guides users through replacing UI action strings with custom-defined actions for better control over the character's movement. It concludes with a summary of the completed tasks and an invitation to subscribe for more content, highlighting the completion of all the outlined objectives for the tutorial.
Mindmap
Keywords
💡Godot Engine
💡Scene
💡Node
💡TileMap
💡Sprite
💡CollisionShape2D
💡Subscene
💡GScript
💡Animation
💡InputMap
💡Physics Layers
Highlights
Introduction to creating a platformer game using the free and open-source Godot engine.
Installation process of Godot engine and initial setup for a new project.
Explanation of the Godot main editor window and its various panels and tabs.
Creating a scene as a container for in-game components in Godot.
Saving the scene and naming conventions for Godot scene files.
Setting up the 2D mode and creating the game window border.
Adding a background to the game scene using a texture.
Using anchor presets to ensure the background covers the entire screen.
Importing and setting up a tile set for the game's ground.
Creating a tile map and painting the ground tiles for the character to walk on.
Adding a character to the scene with a sprite and a collider.
Creating subscenes for better organization and reusability of game elements.
Running the game and initial testing of the character's movement.
Scripting the character's movement controller using GScript in Godot.
Fixing character collision with the ground by setting up physics layers.
Adding animations to the character for idling, jumping, and running.
Implementing smooth movement and jumping mechanics through script adjustments.
Customizing input mappings for character control beyond the standard arrow keys.
Completion of the tutorial with a fully playable basic platformer game in Godot.
Transcripts
if you're just starting your game def
Adventure or you're trying out a new
game engine it's good to start with
Basics Tod platformer game we'll create
it in goo a free and open source engine
that will allow you to create your first
Dream project we'll be touching a lot of
Concepts so stick to the very end to
collect all their badges if some of the
workflows require revision don't forget
to explore video Chapters at the bottom
of the video after each chapter you will
receive a new badge first let's install
godo visit the official website click
download latest and then godo engine
after installation you will be greeted
with this screen press new project PR
the puff and create a new directory that
will hold all your future goo projects
give your new project a name and click
create folder that way you will have a
nice structure for this and future
projects as for the renderer select
mobile option it's the best choice for
2D game click create and edit this is
the gdo main editor window here we'll be
doing all of our work as you can see
there are multiple panels and tabs which
we be discovering along the way first
thing we need to do is to create our
scene scene is a container that gathers
all the in-game components both static
and the dynamic ones as you can see here
in the top left goto gives us some
starting suggestions but I would prefer
to have a blank canvas click on other
node and from this scare window just
select default white node and click
create this will be our root of the
scene and all other components will be a
child of it that helps to keep our
project tidy before we'll start adding
child notes we need to save our scene
just click control or command s name it
main. dscn which is a godo scene format
and click save save after it's saved you
can find it here in the file structure
of a project congrats this is your first
badge today we'll create only 2D
elements so here at the top select 2D
mode and zoom into the blue border it
represents our game window our scene
will consist of three main elements
background ground blocks where our
character will be able to walk and a
character let's start with the first one
today for all the graphics I'll be using
this awesome free pack called pixel
Adventure download it from the link
below I'll take the green background
image and drag it into the goo file
system section that way it will become a
part of our project to fill the whole
background withd let's create our first
Noe click on this small plus icon in the
Sy Tab and search for texture wrecked
node click
create this component allows us to show
an image on the scene simply drag this
image from the file system to the
texture field right here that way it
shows up on the scene now I would like
to resize it to the whole size of the
screen resizing man is not a good idea
because everything may break after the
window resizes what we need to do is to
click on this small green icon at the
top and from the anchor preset select
four wrecked to learn more about Ancor
presets you can check out this video to
other small tweaks first I don't like
that this pixelated image is being
blurred to fix that here in the
inspector find the texture section and
change filter to nearest much better and
the second one instead of stretching
this image I'd like to tile it here in
the stretch mode select tile
great now now let's create a ground on
which our character will be walking for
that we'll use a GRE til set system
which allows us to easily paint our
scene objects you may recognize it from
many popular games both in the side view
and in the top down view I'll import
this terrain file to use it let's create
a new note right click on the rout
select ADD child node and search for
tile map to start drawing tiles we need
to do a onetime configuration ation of a
tile set here in the inspector click on
empty and select new tile set in this
new window on the bottom we only need to
drag our terrain image here click yes
and goto will automatically split our
tile set for us into small individual
tiles now to draw them on the scene
simply switch the tab on the bottom to
tile map select tile and start dragging
your mouse on the scene again two small
fing to make this experience better
first let's increase the size of our
tiles so that everything will be bigger
on the scene go to transform and change
scale to three and the second one if we
zoom in we can see the same problem with
smoothing out pixels go to texture and
set filter to nearest way better now is
the time for you to become a level
designer you can play with all the
available tiles and tools like paint
line or rectangle Le you can also select
multiple Tiles at once and paint them in
batches and when you make a mistake just
use an eraser to cleaned now I'll take a
second to Z my level in the meanwhile
you can leave a like under this video if
you're enjoying it so far also here is a
silver badge for you you'll learn one
more skill related to TI Maps later in
this video all right here is what I
created I think it will be a nice level
to play around remember to play some
bricks around around the scene so that
player does not fall off the map but
obviously something is missing our main
character time to create one create a
new note called character body 2D it
should be a child of root so if you made
the same mistake just drag it like that
character control needs to have two
children Sprite that will Define its
image and a collider that will Define
what touches the ground and collides
with other elements on the scene let's
start with the first one create a new
note called Sprite 2D similarly to the
background it also waits to add a
texture to it I will import this ninja
frog and set it as a Sprite texture if
you think your character should be a bit
bigger simply resize it and again just
like with all other images I'll change
the texture filter to nearest then
collider select the character body and
add a new note called Collision shape
ape 2D for now it hasn't created any
collider because we need to change a
setting here in the inspector instead of
empty go with the rectangle shape 2D
that created this blue box don't worry
it won't be visible in the game it only
visualizes to what shape will collide
with other objects resize on the bottom
Edge so that it will reflect the place
where player will be touching the ground
colliders on the sides are not that
important but you can simply resize them
to the entire frog image these are the
basics of creating Sprites good job if
you'd like to create enemies you can do
so by using the same node structure
remember to experiment with different
Collision shapes time for the very
important skill creating subscenes our
character is initially placed here in
the corner obviously not an ideal place
so I'm going to move it the problem is
that I'm not not moving the whole parent
but only the collider or the Sprite to
move everything we need to create a
subscene we can also call it a group or
a prefab if you're coming from Unity
right click on character body and select
Save branch as scene now we need to set
the location create a new folder called
scenes rename our scene as main
character and click save that did two
things first we can now find our newly
saved subscene here in the file system
and the second our few notes have been
combined into this one I can now freely
move this subject with all of its nodes
at once if you like to change anything
for this character just double click it
that will open a new tab with only this
scene contents what is really important
anything changed here will also apply to
the main scene for example I will change
the collider shape to capsule resize it
a bit and press command or contrl S now
in the main window this change is
applied that can be even more useful for
changing multiple subscenes at once for
example here I have an enemy subscene
that I placed a few times in our world
if I open it change the rotation of the
Sprite and save it you can now see that
all of the enemy instances have been
updated remember to often create
subscenes to keep your project tidy
let's try to play our game here in the
top right click run project a new window
will appear and after a second of
loading you should see your amazing game
for now we can't really do much our
character is not moving let's fix that
go to the main character scene click on
the root node and click the small ad
script icon we leave all of those values
by default but let's quickly go over
them first you select your programming
language we'll go with g script but if
you'd like to try out C check out my
other video and follow the script
alternative version shown on the screen
then select a template goo has a
built-in template for moving to the
characters which we'll use for sure and
finally set a file location and name
it's a good practice to name it the same
as the scene click create whoa as you
can see goto has switched to the script
tab if you like to go back to the editor
you can do it here this is the template
code for the character controller the
good news is that it already works and
we can test it out go to the 2D Tab and
save the scene notice that the unsaved
changes have the small star next to them
press play now our game starts the main
character starts falling and falls
through the map what's wrong the problem
is that our whole character has the
Collision remember this blue box shape
but but our ground does not the game
simply doesn't know what to collide with
the fix is very easy but requires a few
clicks select the tile map in the SC tab
then here in the inspector click on tile
set then physics layers and click add
element now go to this bottom section
select tile set tab don't mistake it
with ti map in a paint tool set paint
properties to the physics layer and
finally paint all the tiles that should
collide with the player in my case all
of the ground tiles and the rope and
that's it now when I press play our
character will start colliding with the
ground perfect to control it use
keyboard arrows and to jump press space
congratulations on creating your first
movement controller in goo before we'll
move on with a nicer movement I'd like
to quickly go back to our Sprite
appearance currently it's just stands
without any life we can easily fix that
by giving it a simple idle animation go
to the main character scene I would like
to replace this Sprite with a node that
enables animation right click on it and
select change type we'd like to change
it to the animated Sprite 2D our image
disappeared but don't worry we'll
quickly reverted in the inspector select
animation and next to the Sprite frames
click and empty and select new Sprite
frames I'd like to use this idle
animation frames which can be found in a
pack import them to godo and here in the
Sprite frames panel on the bottom click
add frames from Sprite sheet select ID
animation file here godo is asking us
how we would like to split this image in
this case I know that each frame is 32x
32 so we can enter it here alternatively
you can can also experiment with
horizontal and vertical values until the
image will be split correctly then we
need to select all the animation frames
simply click on the first one and drag
your mouse along all the others that
will create 11 frames add them now our
animation is ready to preview it click
this play button if the animation seems
a bit too slow you can increase the
frames per second value before we move
on let's let's create two other
animations that we'll use later on
jumping and running for jumping that
will be only one frame we've used before
I will just click add frame from file
and import this full image for running
we'll use this Sprite sheet go ahead
pause the video and try to add it right
now all right here is what you need to
do import running image in the Sprite
frame switch to the running animation
and press this button select the file
slice it properly select all the frames
preview the animation and change its
speed to play the animation in the game
select the default one and press the
small button that will turn on out to
playay on load that's it play the game
and enjoy how our character plays the
animation we'll work on implementing the
other animations a bit
later as promised let's get back to the
scripting as you can see our movement
works but it's quite lifeless and stiff
time to change that switch to the script
Tab and look at main character script it
is very short and quite understandable
thanks to the comments basically what's
happening is that 60 frames per second
we are doing three things first we check
if our character is not touching the
ground which means it's in the air in
such cases we we apply a gravitational
force that pulls it towards the ground
it's worth noting that in gdo the y axis
operates differently than the standard
graph convention with positive values
directed towards the bottom then we
check if player is both on the floor and
has pressed jump button in such case we
should increase the velocity towards up
and lastly we check if player is
clicking either right or left button in
such case we should change the velocity
towards either of the sides and that's
it pretty simple we'll have three tasks
here flip character right or left
depending on the movement play character
animations depending on what's Happening
and finally make walking and jumping a
bit smoother and nicer to play with
let's start with the first one if we
take a look at our animated Sprite you
can see that in the offset section there
is this nice togle to flip Sprite
graphics horizont onally we need to
toggle it in the script depending on
what was the last player velocity
direction accessing nodes and their
values in the script is very easy switch
to the script Tab and start dragging
Sprite to denote from the scene to code
like that very important just before the
mouse release hold the control key that
will create a reference that can be used
in different parts of the script now at
the very end of this function we simply
need to add two lines VAR is left that
will be a variable that will check if
player is facing the left or the right
side of the screen we know that by
checking if the velocity. x is lower
than zero if player is facing left that
means that we'd like to flip its image
type Sprite Tod flipcore H which stands
for horizontally equals is left that
should be it Run the game and notice how
our character is changing its size
depending on the movement Direction next
playing different animations now that we
have a Sprite animator reference that
will be very easy as a reminder we have
three animations default jumping and
running to change animation for example
while jumping just type here Sprite Tod
do animation equals jumping now when
whenever our character is in the air the
jumping animation starts to implement
animations for walking and sending here
is the code I will add at the very top
of our function if velocity. x is
greater than 1 or lower than minus one
we need to cover both right and left
movement then sprite td. animation
equals running else sprite td. animation
equals default remember that those
strings need to have the exact same
names as defined earlier now press play
and notice how our character is nicely
animated it even plays jump animation
when falling off the hill and the last
step where all the magic will happen
will tweak some controller values first
I like to look at this line what it does
is that when the player stops holding
the right or left key the character
should gradually slow down function move
toward takes current velocity which at
maximum is currently 300 and brings it
slowly back to zero using steps the
problem is that by default the steps are
defined using the same variable as the
maximum speed that causes the instant
speed drop when the key is no longer
pressed I would suggest inputting
something smaller here for example value
10 that way we'll get this fun slowing
down effect what is great about gdo is
that you can tweak some variables
without stopping the game for example if
I would change that to four and save the
player will behave as it it's on the
eyes I think 12 is an optimal value now
how about the other values when you
scroll up you can see those three
variables speed which is a max speed
character can travel with jump velocity
and gravity let's start with the last
one its value is taken from the project
settings so go to project project
settings search for Gravity it will be
in the physics 2D and change it to
something bigger like
2500 I'll increase the speed to 400 and
the jump velocity to minus 900 remember
minus values are going upwards after all
of those changes press save start the
game and try it out in in my opinion
it's way better than what we started
with that was a long chapter so here is
a great reward scripting gold badge good
job time for the last Quick addition for
now we can only use arrows and space to
control our character but what if you'd
like to add other Keys when you check
out the script you can see that we
Define key presses using the UI accept
left and right this is not ideal those
mappings should be used only for the
user interface and in fact code commands
tell us exactly that we need to replace
them with manually defined actions go to
project project settings and select the
input map tab at the top here we can
declare actions and key mappings here
type left and press return I will also
add the same way right and jump under
each of the sections we'll Define all
keys that should trigger it click the
plus icon next to the left action and
press the left Arrow key it should
automatically find the key you are
looking for I will do it again for the a
key to enable A and D movement finally
if you'd like your game to support the
GamePad you can search for left stick
left and d-pad left I think that should
be it now pause the video and complete
this input map with all the remaining
key combinations for your
game all right here is my final
configuration to apply it in the code
all we need to do is to replace those UI
something strings with jump left and
right that's it that way you just
completed all the budgets for this video
congratulations if you liked this
tutorial subscribe to Coco code and
check my other videos as always big
thanks to my awesome patrons that
support this channel visit a link under
the video to join them see you soon
Ver Más Videos Relacionados
How To Make A Video Game - GDevelop Beginner Tutorial
How To Make a Topdown RPG in Godot 4: Adding The Player (Part 1)
How To Make a Topdown RPG in Godot 4: Adding Combo Attacks and an Enemy(Part 2)
Space Shooter in Godot 4 - part 1 (introduction)
How To Make A Game with GDevelop - Juice (E10)
Cara Membuat Tetris sederhana untuk pemula di Mit App inventor GRATIS 2024 | programmer pemula
5.0 / 5 (0 votes)