• 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 1: Create movement for the character

AnonyViet by AnonyViet
February 1, 2025
in Tips
0

Okay, and welcome to the series Game programming with Godot Engine 3.2 And today I will guide you to move up, down, left and right for my first character.

Join the channel Telegram belong to Anonyviet 👉 Link 👈

Create character

First we open the software. Please pay attention to the section scene

scene

This is where you will do your node. View Post What is node?

Here you can choose Other Node Or 2D Sense All. This article I choose Other Node

When created, it will appear below, and I change my name World:

[Lập trình Game]  Lesson 1: Create movement for the character

Next, press the mark + Or press the combination Ctrl + A To create new nodes under the world

And you find Kinematicbody2d for yourself:

[Lập trình Game]  Lesson 1: Create movement for the character

Then stay Kinematicbody2d select Collsetshape2d and Sprite okay

Kinematicbody2d

And here after creating you have 1 character moving Basic can be anything (the main character, the enemy, ..)

Kinematicbody2d: Means dynamic body (used to create objects as 1 character)

Sprite: Used to create photos for your character

Collsetshape2d: The collision shape (used to determine the collision with another object)

Part Sprite You click and drag icon.png Or any image you want to make a character, dragging into the texture.

pull icon.png

And here it has appeared:

[Lập trình Game]  Lesson 1: Create movement for the character

Next click Collsetshape 2D and in Inspector select Shape> New Rectangles2d

[Lập trình Game]  Lesson 1: Create movement for the character

At the character's face interface, you Pull the dot in the blue line and the red dot in the purple line so that it is equal to the sprite.

[Lập trình Game]  Lesson 1: Create movement for the character

Code for character moving

So already Done the character creation Next is the code.

Click on Kinematicbody2d And choose for yourself as a photo to create a script:

Create script

Script: The place where you will code and code will apply to run your game and character

Attach Node Script

  • Language: Language used for programming
  • Path: Path to save
  • Load: Create script

And press Load.

After clicking Load, the code interface will appear, ban Delete all content from line 4 to line 17

Code interface

Declare variables

Get yourself a variable declaration code as follows:

[Lập trình Game]  Lesson 1: Create movement for the character

Anyone who programmed then knows how to declare the variable ^^ Basically and whoever does not know, I explain the following:

Var: Declare a variable to use it. Example: Var Tocdodichuyen, Var Ketqua, Var huongdichuyen

So Var Chuyendong = Vector2 () in which Vector2 () is?

Vector2 (): A variable used for mathematics in 2D and in mathematics, you know the coordinate axis x, y, …

Here:

  • x = horizontal motion
  • y = straight motion
  • FUNC _PHYSICS_PRocess is a physical process that means the movement of kinematicbody2d
  • FUNC _READY is the process of ready: When you declare a variable in Ready it will be loaded when downloading the game

And in Physics_process, you also declare a variable as above, but when it moves it, it will be loaded

Pass: yes it is okay

Motion code

Code for me the following paragraph. This is the code Right motion, left

Motion code

In here I will explain the paragraph IF statement okay. Whoever learned programming, the IF statement is not difficult

if input.is_ACTION_Prisheded (“UI_RIGHT”): is: When you press the right arrow key, it will move to the right and vice versa Elif is left and Else: It will stand still after moving.

Move_and_slide (move and surf): Help your character move

Press F5 or F6 To try it out.

F5: Run the default scene

F6: Running Scene is editing. Example: worldnumberone is the default scene and worldnumbervietnam Is scene being edited. When pressing F5 even in scene worldnumbervietnam Then it will run Worldnumeberone If pressed F6 it will run worldnumbervietnam without running Worldnumeberone )

If it is like this, you can adjust it:

Error

Click as photos:

[Lập trình Game]  Lesson 1: Create movement for the character

We are as photos:

Lock moving

When you press this it will help you Fix the ingredients inside it.

And if you press the lock, it will Node lock Again on the screen can not be transferred and cannot press

Then we pull it out between:

[Lập trình Game] Lesson 1: Create movement for the character

If this is like this, press the right arrow and the left to see it moves:

See left and right motion

If you want Move up, down then the code is as follows:

[Lập trình Game]  Lesson 1: Create movement for the character

And I have instructed you to program a basic character, then the next article will be about: Friction force after running, gravity, jump, ground.

Goodbye and see you again in the following article.

Deathgm!

Previous Post

How to use LMSTUDIO to install AI offline on PC running Deepseek, Sonet …

Next Post

How to use chatgpt O3 for free

AnonyViet

AnonyViet

Related Posts

Cách Đăng ký Nhận Code ChatGPT Business
Tips

Cách Đăng ký Nhận Code ChatGPT Business

November 2, 2026
Instructions for cleaning LG TV with Antigravity to help it run faster
Tips

Instructions for cleaning LG TV with Antigravity to help it run faster

October 30, 2026
Quét lỗ hổng bảo mật cho Vide Coding bằng Security Audit Skill
Tips

Quét lỗ hổng bảo mật cho Vide Coding bằng Security Audit Skill

October 27, 2026
Instructions for registering for OxionAI Pro for 1 year with many powerful AI models
Tips

Instructions for registering for OxionAI Pro for 1 year with many powerful AI models

October 24, 2026
How are Windows 11 Pro and Windows 10 Pro different?
Tips

How are Windows 11 Pro and Windows 10 Pro different?

October 23, 2026
Instructions for using CleanYourTV: Remove ads on Android TV, Google TV
Tips

Instructions for using CleanYourTV: Remove ads on Android TV, Google TV

October 23, 2026
Next Post
How to use chatgpt O3 for free

How to use chatgpt O3 for free

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted

Recent News

HuiPai AI Pro Camera: App that automatically aligns photo angles for free on iPhone

HuiPai AI Pro Camera: App that automatically aligns photo angles for free on iPhone

November 7, 2026
Instructions on how to buy super bargain 1k Bach Hoa Xanh products

Instructions on how to buy super bargain 1k Bach Hoa Xanh products

November 6, 2026
Besides the 7500 mAh battery and 6.9 inch screen, what else does the POCO C95 Pro 4G have to make it a secondary device worth buying?

Besides the 7500 mAh battery and 6.9 inch screen, what else does the POCO C95 Pro 4G have to make it a secondary device worth buying?

November 5, 2026
App fixes printer errors automatically, effective immediately with 1 click

App fixes printer errors automatically, effective immediately with 1 click

November 5, 2026
HuiPai AI Pro Camera: App that automatically aligns photo angles for free on iPhone

HuiPai AI Pro Camera: App that automatically aligns photo angles for free on iPhone

November 7, 2026
Instructions on how to buy super bargain 1k Bach Hoa Xanh products

Instructions on how to buy super bargain 1k Bach Hoa Xanh products

November 6, 2026
Besides the 7500 mAh battery and 6.9 inch screen, what else does the POCO C95 Pro 4G have to make it a secondary device worth buying?

Besides the 7500 mAh battery and 6.9 inch screen, what else does the POCO C95 Pro 4G have to make it a secondary device worth buying?

November 5, 2026
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

HuiPai AI Pro Camera: App that automatically aligns photo angles for free on iPhone

HuiPai AI Pro Camera: App that automatically aligns photo angles for free on iPhone

November 7, 2026
Instructions on how to buy super bargain 1k Bach Hoa Xanh products

Instructions on how to buy super bargain 1k Bach Hoa Xanh products

November 6, 2026
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

say88 tỷ lệ kèo nhà cái kèo nhà cái 5 febet

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

say88 tỷ lệ kèo nhà cái kèo nhà cái 5 febet

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