• Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
AnonyViet - English Version
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office
No Result
View All Result
AnonyViet - English Version
No Result
View All Result

[Lập trình Game] Lesson 5: Programming character movements

AnonyViet by AnonyViet
January 23, 2025
in Tips
0

As you know, every game has a character and most 2D games have a main character who is generally the character you control for ease of understanding. Today I will guide you to create character movements. This article includes 2 parts as well as 2 types of character creation. Why are there 2 parts? Because it depends on your assets because most of the time there are 2 types of assets: 1 type is movement according to each image and 1 type is movement located all in 1 image.

Join the channel Telegram belong to AnonyViet 👉 Link 👈

You need to study from lesson 0 to this lesson to fully understand the instructions Game programming with Godot okay.

And without further ado, let's get started

Character Animation:

I will guide you to do type 1 first.

Let's get started:

First: Delete Sprite old and created for yourself AnimatedSprite

programming Godot game character movements

AnimatedSprite: A node that can use many image textures to create movement

Here I guide you to use my assets and if any of your assets are different from mine and are in the same category as below, you can apply. It has many separate photos

Player download link

Link to download motion programming game characters

Please download and put it in the game folder

image003

Next we will create the character

Click on AnimatedSprite and change the name to Player, then on the right side of Player there is a setting column in the Frames section to create a new Frame for yourself.

code Godot character movement

Then click on the newly created SpriteFramse and a table will appear (click like a tilemap).

Write character movement code

Here you can see on the left there is the word default, you can delete it and create a new animation

Click as shown to create new Animations

image006

Create 4 for yourself: Idle – Run – Jump – Fall

In Idle, drag all the folders into it

image007

image008

Do the same with the other parts

And in the Jump section

image009

Pay attention to mines anim8 and anim11

Anim8 is jump and anim11 is fall, why? Because 8 is when you jump and 11 is when you land. You can do the same with other assets. If you don't understand, you can inbox me or go to Group Anonyviet Community to ask.

If your character is blurry like an image from Import back into 2D pixels

image010

Please change each one in the FIlesystem section

After editing, our character will be sharpened again

image011

And we are done with the Character Creation part. Next is the Coding part

And you can adjust the collsion for yourself

image012

Game character movement code

And I will guide you through coding for character movements. Your game character can move according to the keys you programmed.

Partless script > character

Give me the code to add the following part

image013

Line: 12 – 13 – 16 – 17 – 20 – 24 -25 -26- 27 – 28

And below I will explain to you

$Player: means you call Node in the script section using $ to call any Node in a Node

$Player.play(): is you run the Animation you did just now

$Player.flip_h: is it helps you turn left and right if you try removing these 2 lines and then running the game moving left + right you will see something different than if you don't remove these 2 lines

From line 24 > line 28 is a piece of code that helps you jump while still being able to apply animations.

After running the game we will have a complete character:

image014

In the next episode, I will guide you to create friction to control your speed. When you move, you will see it running really fast, so there will be another thing: friction.

Previous Post

SAP B1 and SAP S/4HANA: Which ERP solution is suitable for businesses?

Next Post

How to aggregate personal data using ChatGPT

AnonyViet

AnonyViet

Related Posts

10 languages ​​for web programming should learn in the isolation season
Tips

10 languages ​​for web programming should learn in the isolation season

June 16, 2025
Ruby vs Python: Where is the better language for application programming
Tips

Ruby vs Python: Where is the better language for application programming

June 15, 2025
Instructions for health drive health check on your computer
Tips

Instructions for health drive health check on your computer

June 14, 2025
PHPSOUND 6.2 – Code to build social networks to share music
Tips

PHPSOUND 6.2 – Code to build social networks to share music

June 13, 2025
How to detect and prevent email monitoring from others
Tips

How to detect and prevent email monitoring from others

June 12, 2025
8 free tools to security when programming software
Tips

8 free tools to security when programming software

June 11, 2025
Next Post
How to aggregate personal data using ChatGPT

How to aggregate personal data using ChatGPT

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

From Ho Chi Minh City to London: How Global Investors Use Bow Miner to Efficiently Minine Cryptocurrencies

From Ho Chi Minh City to London: How Global Investors Use Bow Miner to Efficiently Minine Cryptocurrencies

June 17, 2025
How to activate Adaptive Power on iOS 26 to save battery

How to activate Adaptive Power on iOS 26 to save battery

June 17, 2025
How to adjust the time to postpone the alarm iOS 26

How to adjust the time to postpone the alarm iOS 26

June 16, 2025
10 languages ​​for web programming should learn in the isolation season

10 languages ​​for web programming should learn in the isolation season

June 16, 2025
From Ho Chi Minh City to London: How Global Investors Use Bow Miner to Efficiently Minine Cryptocurrencies

From Ho Chi Minh City to London: How Global Investors Use Bow Miner to Efficiently Minine Cryptocurrencies

June 17, 2025
How to activate Adaptive Power on iOS 26 to save battery

How to activate Adaptive Power on iOS 26 to save battery

June 17, 2025
How to adjust the time to postpone the alarm iOS 26

How to adjust the time to postpone the alarm iOS 26

June 16, 2025
AnonyViet - English Version

AnonyViet

AnonyViet is a website share knowledge that you have never learned in school!

We are ready to welcome your comments, as well as your articles sent to AnonyViet.

Follow Us

Contact:

Email: anonyviet.com[@]gmail.com

Main Website: https://anonyviet.com

Recent News

From Ho Chi Minh City to London: How Global Investors Use Bow Miner to Efficiently Minine Cryptocurrencies

From Ho Chi Minh City to London: How Global Investors Use Bow Miner to Efficiently Minine Cryptocurrencies

June 17, 2025
How to activate Adaptive Power on iOS 26 to save battery

How to activate Adaptive Power on iOS 26 to save battery

June 17, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET 23win https://kubet88.yoga/ KUBET BK8 Bj88

No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

©2024 AnonyVietFor Knowledge kqxs hôm nay xem phim miễn phí SHBET 23win https://kubet88.yoga/ KUBET BK8 Bj88

wpDiscuz
0
0
Would love your thoughts, please comment.x
()
x
| Reply