• 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 moves for the character

AnonyViet by AnonyViet
February 3, 2023
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, right for my first character.

Join the channel Telegram belong to AnonyViet 👉 Link 👈

Character creation

First we open the software. You pay attention in Section scene

scene

This is where you will implement your Node. View Posts What are Nodes??

Here you can choose Other Node Or 2D sense all okay. This article I choose Other Node

Once created, it will appear below, and I renamed it World:

[Lập trình Game]  LESSON 1: Create moves for the character 12

Next, press the sign + or press the combination Ctrl + A to create a new Node under World

And you find KinematicBody2D for myself:

[Lập trình Game]  LESSON 1: Create moves for the character 13

Then stay KinematicBody2D select CollsionShape2D and Sprite Please

KinematicBody2D

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

KinematicBody2D: Means Kinetic Body (used to create object like a character)

Sprites: Use to create your character’s photo

CollsionShape2D: Collision shape (used to determine where to collide with another object)

In the sprite you click and drag icon.png or any other image you want to use as a character, drag into the texture.

drag icon.png

And here it appeared:

[Lập trình Game]  LESSON 1: Create moves for the character 14

Next click on CollsionShape 2D and stay Inspector select Shape > New RectangleShape2D

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

At the character’s face interface, you drag the dot on the blue line and the red dot on the purple line so that it is equal to the sprite.

[Lập trình Game]  LESSON 1: Create moves for the character 16

Code for the character to move

So that’s it Finished character creation Next is Code.

You click KinematicBody2D and choose for yourself as the image to create the script:

create scripts

Script: Where you will code and that code will apply to run the game and your character

attach node script

  • Language: The language used for programming
  • Path: Path to save
  • Load: Create scripts

And press Load.

After clicking Load, the interface of the Code writing page will appear delete all content from line 4 to line 17

code interface

Declare variable

Type yourself a code that declares a variable as follows:

[Lập trình Game]  LESSON 1: Create moves for the character 17

Anyone who has programmed, knows how to declare a variable. ^^ It’s basic and for those who don’t know, I’ll explain as follows:

var: declare a variable to use it. VD: var tocdodichuyen, var ketqua, var huongdichuyen

So what is var conversion = Vector2() where Vector2() is ?

Vector2(): is a variable used for math in 2D and in math, you know the x, y coordinate axes, …

in here:

  • x = horizontal movement
  • y= straight motion
  • func _physics_process is a physical process i.e. kinematicbody2D
  • func _ready is process ready: when you declare a variable in ready it will be preloaded when the game loads

In physics_process, you also declare a variable as above, but it is loaded when it moves

pass: yes or no

Motion code

Code for me the following part. Here is the code right and left movement

motion code

Here I will explain the passage if . statement Please. Who has learned programming, the if statement is no longer difficult

if input.is_action_pressed(“ui_right”): is: when you press right arrow key it will move right And vice versa with elif is to the left and else: is that it will stay still after moving.

move_and_slide (move and glide): make your character move

Press F5 or F6 for a test run.

F5: run default scene

F6: run the scene being edited. VD: worldnumberone is the default scene and worldnumbervietnam is the scene being edited. When pressing F5 even in the scene worldnumbervietnam then it will run worldnumeberone if press F6 it will run worldnumbervietnam without running worldnumeberone )

If it is like this, you can edit it:

run error

Click as picture:

[Lập trình Game]  LESSON 1: Create moves for the character 18

We get as picture:

move lock

When you press this it will help you fix the components inside it.

And if you press the lock it will node lock back on the screen can’t move nor can’t press

Then we drag it to the middle:

[Lập trình Game] LESSON 1: Create moves for the character

Okay like this, you press the right and left arrows to see it move:

watch left-right movement

If you want up and down movement then the code is as follows:

[Lập trình Game]  LESSON 1: Create a move for the character 20

And I have instructed you to program a basic character, then the next lesson will be about: Friction force after running, Gravity, Jumping, Ground.

Goodbye and see you in the next post.

DeathGM!

The article achieved: 5/5 – (100 votes)

Tags: charactercreateGamelậpLessonmovestrình
Previous Post

License Key Visual Studio 2019 (Professional/Enterprise)

Next Post

Share license key Visual Studio Enterprise 2019

AnonyViet

AnonyViet

Related Posts

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
How to use Messenger without a Facebook account
Tips

How to use Messenger without a Facebook account

October 22, 2026
The website helps you draw beautifully like TikToker Viet My
Tips

The website helps you draw beautifully like TikToker Viet My

October 21, 2026
Instructions on how to hard reset iPhone 18 Pro / iPhone 18 Pro Max
Tips

Instructions on how to hard reset iPhone 18 Pro / iPhone 18 Pro Max

October 21, 2026
Next Post
Share license key Visual Studio Enterprise 2019

Share license key Visual Studio Enterprise 2019

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted

Recent News

Postpaid for new employees: Should you start using it?

Postpaid for new employees: Should you start using it?

October 26, 2026
How to create a UFO Game that calls students to return their homework

How to create a UFO Game that calls students to return their homework

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

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?

How are Windows 11 Pro and Windows 10 Pro different?

October 23, 2026
Postpaid for new employees: Should you start using it?

Postpaid for new employees: Should you start using it?

October 26, 2026
How to create a UFO Game that calls students to return their homework

How to create a UFO Game that calls students to return their homework

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

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

October 24, 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

Postpaid for new employees: Should you start using it?

Postpaid for new employees: Should you start using it?

October 26, 2026
How to create a UFO Game that calls students to return their homework

How to create a UFO Game that calls students to return their homework

October 26, 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