• 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

[Godot RPG] #3: Attack & Object

AnonyViet by AnonyViet
May 30, 2025
in Tips
0

Welcome to Lesson 3 in the RPG game programming series with Godot: 3

Join the channel Telegram belong to Anonyviet 👉 Link 👈

Okay, in this article I will guide you to attack with Animation Player & Hitbox & Hurtbox and Object with Godot

And let’s start

Attack

We will create a new sense to make hitbox to check when we attack and hurbox to check when the hitbox it collides with blood loss.

Hitbox & Hurtbox

Create the hitbox and the original button is Area2D and then add the collisionshape2d.

[Godot RPG]  #3: Attack & Object 35

Then create a new script

[Godot RPG]  #3: Attack & Object 36

Here I will use the Export variable to export to the Inspector for easy adjustment for each character. You can adjust the language outside Godot’s interface to Vietnamese for ease

[Godot RPG]  #3: Attack & Object 37

Then save it.

Then create the new sense is Hurtbox then save like hitbox and no need to create script because we will connect the signal to the Player

[Godot RPG]  #3: Attack & Object 38

Click and then beat

We have to check if clicking, then attack. You can edit the input if lazy, use as photo: etc. Godot has many options!

[Godot RPG]  #3: Attack & Object 39

Then the state will be equal to Attack.

In Attack: We will create a new function is TrangThai_attack will have code running Animtion Attack

[Godot RPG]  #3: Attack & Object 40

Then next you call it on Attack: okay.

Then when we attack we have to set Speed ​​= 0 so that when it attacks it will not move

[Godot RPG]  #3: Attack & Object 41

After the attack is completed, it will stand still because it has not returned to IDLE state so we have to set it back.

I will create a new function

[Godot RPG]  #3: Attack & Object 42

Then in Animationplayer> Animation Attack> Add track method (this is the track that will run the Godot function with this convenient: 3)

[Godot RPG]  #3: Attack & Object 43

Then select Player because the new Player has the code to run: D

[Godot RPG]  #3: Attack & Object 44

Then choose the jaw

[Godot RPG]  #3: Attack & Object 45

Then adjust it to the end because at the end of animation = run the jaw

[Godot RPG]  #3: Attack & Object 46

And so you will move normally

Instance & Animation Player

Next we will instance it in Godot. Instance I don’t know what to call Vietnamese @@.

Then click Add 2 hitbox & Hurtbox then right -click 2 press Editable as Children so we can adjust it as a sub -button and set Collishape.

[Godot RPG]  #3: Attack & Object 47

Well before that, we had to set the mask/layer. Visit Project> Project Setting> 2D Render / 2D Physics

You guys set like me. Set for both 2D Render and 2D Physics

[Godot RPG]  #3: Attack & Object 48

Then in the player’s hitbox on the attribute table> Collision, I will remove the tick in the layer and in the mask will tick it collide with Hurtbox_e, which means that when the player attacks it will collide with Hurtbox of the enemy.

[Godot RPG]  #3: Attack & Object 49

[Godot RPG]  #3: Attack & Object 50

Then at Hurtbox Layer, you ticked in the hurbox_p box in the blank mask

[Godot RPG]  #3: Attack & Object 51

Next is to adjust the collisionshape2d of Hurtbox to fit the character.

[Godot RPG]  #3: Attack & Object 52

Then will set Collisionshape2D of hitbox with animationplayer.

In hitbox’s collisionshape2d, press the key to add track quickly

[Godot RPG]  #3: Attack & Object 53

[Godot RPG]  #3: Attack & Object 54

Then you will watch the position when it attacks / off.

Because it has not been attacked, I will leave disabled = true on second seconds and then check the next few seconds if you come to the attack, set disabled = false and then after drawing, disabled = true

[Godot RPG]  #3: Attack & Object 55

[Godot RPG]  #3: Attack & Object 56

Then running again will find it okay and Perfect: 33. I like this in Godot extreme

Object

Next we will create object with Godot.

Download link: https://elthen.itch.io/pixel-art-destructible-Objects

Create a new sensing

Here created:

Area2d> Sprite – Collisionshape2d – Animationplayer

[Godot RPG]  #3: Attack & Object 57

In Sprite, put the image in and I feel a bit loud, you set the scale accordingly.

Vframes = 12

Hframes = 7

[Godot RPG]  #3: Attack & Object 58

Fuzzy Reimport again.

[Godot RPG]  #3: Attack & Object 59

Then next in the Animationplayer creates 2 animations: hit and Destroy. The hit is animation when hitting and Destroy is animation when destroyed.

Here I will be the box you want to change.

Hit: 7-9

Destory: 10-13

At the Animation Destroy I will apply the similar Call Method above.

Destroy () contains queue_free () statement

[Godot RPG]  #3: Attack & Object 60

Then create a new script. Here we do not need hitbox or hurbox because this barrel is already an Area2D button.

We will set Collisionshape2D for it and connect the signal. But note that if you follow the Area2D button like I will have a disadvantage when the player collides with it. If you use staticbody to make it and add Hurtbox, it will be better.

Connect Area Enterd signal.

[Godot RPG]  #3: Attack & Object 61

I will create HP = 10 variable to have a base when the player attacks.

Then at the signal function, I will check if the name Area = “Hitbox”, the HP will be equal to the damage of Area minus HP. The print is that I use it to check HP to see if I hit it yet.

[Godot RPG]  #3: Attack & Object 62

Then set the layer into Hurtbox_e and uncheck the mask.

[Godot RPG]  #3: Attack & Object 63

Next we need to check if the player attacks, we will be saggy hit and when the blood runs out of Animation Destroy

Here I will function _Process (): to check every second if HP <= 0, then run animation and cancel itself

[Godot RPG]  #3: Attack & Object 64

Then next to make sure you at the Animation hit, click the circle under the picture so that when it starts it runs Animation hit, I have to Destroy

[Godot RPG]  #3: Attack & Object 65

Note: Object, at first I created stupid so I sympathized: v. When running the game Đbject will not collide with the player if you want you to adjust to staticbody2d or kinematicbody2d and add hurbox> connect the signal and apply the code as above.

See you in the next post of RPG game programming series with Godot

Previous Post

Discover 3: AI tools turn ideas into professional movies

Next Post

Bắn cá SV388 game bắn cá giải trí và săn thưởng

AnonyViet

AnonyViet

Related Posts

4 ways to fix bluetooth connectivity on Windows 11
Tips

4 ways to fix bluetooth connectivity on Windows 11

August 8, 2025
How to know the computer is tracked and processed by Keylogger
Tips

How to know the computer is tracked and processed by Keylogger

August 7, 2025
Opal: Create applications who do not need to write code
Tips

Opal: Create applications who do not need to write code

August 3, 2025
How to activate a new Start menu on Windows 11
Tips

How to activate a new Start menu on Windows 11

July 29, 2025
Intellgpt: AI tool for osint and data science
Tips

Intellgpt: AI tool for osint and data science

July 28, 2025
How to create Google Ai Pro 12 months free with Indian student account
Tips

How to create Google Ai Pro 12 months free with Indian student account

July 27, 2025
Next Post

Bắn cá SV388 game bắn cá giải trí và săn thưởng

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

Instructions for receiving 80GB of free data from VinaPhone from August 15

Instructions for receiving 80GB of free data from VinaPhone from August 15

August 15, 2025
Online driving exam preparation: Support theory and practice

Online driving exam preparation: Support theory and practice

August 15, 2025
How to add application to your favorite bar

How to add application to your favorite bar

August 14, 2025
Wowhay.com – The door opens the world of modern knowledge and network culture

Wowhay.com – The door opens the world of modern knowledge and network culture

August 13, 2025
Instructions for receiving 80GB of free data from VinaPhone from August 15

Instructions for receiving 80GB of free data from VinaPhone from August 15

August 15, 2025
Online driving exam preparation: Support theory and practice

Online driving exam preparation: Support theory and practice

August 15, 2025
How to add application to your favorite bar

How to add application to your favorite bar

August 14, 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

Instructions for receiving 80GB of free data from VinaPhone from August 15

Instructions for receiving 80GB of free data from VinaPhone from August 15

August 15, 2025
Online driving exam preparation: Support theory and practice

Online driving exam preparation: Support theory and practice

August 15, 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í mm88 8XBET mm88 trang chủ new88

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í mm88 8XBET mm88 trang chủ new88

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