• 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 12: Creating HP for Enemy in Godot Engine

AnonyViet by AnonyViet
July 7, 2024
in Tips
0

Continuing with the enemy, in this lesson we will create hp for the enemy and this lesson is quite short, in the next lesson I will guide you to create slash animation (because the available assets of anonyviet do not have slash animation so I will use another animation and if anyone uses another asset that has attack animation then just use it) and destroy the enemy.

Join the channel Telegram belong to AnonyViet 👉 Link 👈

USE EXPORT

Go to the enemy script section and declare your HP variable.

I will declare that:

export var hp = 2

Use export to declare HP variable

And Export here is the declaration command to bring the value out of the table. Properties to edit

Properties panel to edit

You can also do the same with variables if you want and Export it has nothing to do with your code, it only has the function of bringing the variable value out for easier editing without having to edit the code.

[Lập Trình Game] Lesson 12: Creating HP for Enemy in Godot Engine

And you can apply this to many other things.

Here I will guide you a trick to choose something like color, etc.

color changing code

Export (String,”text”) var variablename is to be

Here if you want to change the color you code as follows:

if ColorMode == "Mau Do":
    $Sprite.modulate = Color(0, 0, 1, 1)
elif ColorMode == "Mau Xanh":
    $Sprite.modulate = Color(0.75, 0.75, 0.75, 1)
elif ColorMode == "Mau Cua Anonyviet":
    print(“Dep Trai Khong Bao Gio Sai)

If statement to compare what color is selected

$Call sprite or AnimationSprite or whatever and modulate to change the color

[Lập Trình Game]  Lesson 12: Creating HP for Enemy in Godot Engine

You can func create a function containing the color change command and then call the color change function in physics or process

For example:

# ham process goi du lieu ben trong tren tung khung hinh	
Func _process(delta):
#goi set color
Setcolor()
# ham set color
Func setcolor():
    if ColorMode == "Mau Do":
        $Sprite.modulate = Color(0, 0, 1, 1)
    elif ColorMode == "Mau Xanh":
        $Sprite.modulate = Color(0.75, 0.75, 0.75, 1)
    elif ColorMode == "Mau Cua Anonyviet":
        print(“Dep Trai Khong Bao Gio Sai)
Previous Post

What is Eres El Amor De Mi Vi?

Next Post

How to set password for Android app

AnonyViet

AnonyViet

Related Posts

How to add sliders to Facebook Stories to easily rewind videos
Tips

How to add sliders to Facebook Stories to easily rewind videos

April 21, 2026
How to change the default font on Windows 10
Tips

How to change the default font on Windows 10

April 13, 2026
5 tips for using a Browser to replace an App (helps save RAM, time and money)
Tips

5 tips for using a Browser to replace an App (helps save RAM, time and money)

April 13, 2026
How to make funny MeMe photos without Photoshop within 10 seconds
Tips

How to make funny MeMe photos without Photoshop within 10 seconds

April 11, 2026
How to quickly design your own Logo without Photoshop
Tips

How to quickly design your own Logo without Photoshop

April 10, 2026
How to convert Website into App on Windows
Tips

How to convert Website into App on Windows

April 9, 2026
Next Post
How to set password for Android app

How to set password for Android app

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments

Recent News

Tips for pinning the step counter to the iPhone screen to monitor your health

Tips for pinning the step counter to the iPhone screen to monitor your health

April 28, 2026
How to turn off password suggestions on iPhone: Prevent Safari from auto-filling passwords

How to turn off password suggestions on iPhone: Prevent Safari from auto-filling passwords

April 27, 2026
Instructions for looking up prescriptions on VNeID instead of paper medical books

Instructions for looking up prescriptions on VNeID instead of paper medical books

April 26, 2026
Tips to completely turn off CAPTCHA codes on iPhone and Mac are super simple

Tips to completely turn off CAPTCHA codes on iPhone and Mac are super simple

April 25, 2026
Tips for pinning the step counter to the iPhone screen to monitor your health

Tips for pinning the step counter to the iPhone screen to monitor your health

April 28, 2026
How to turn off password suggestions on iPhone: Prevent Safari from auto-filling passwords

How to turn off password suggestions on iPhone: Prevent Safari from auto-filling passwords

April 27, 2026
Instructions for looking up prescriptions on VNeID instead of paper medical books

Instructions for looking up prescriptions on VNeID instead of paper medical books

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

Tips for pinning the step counter to the iPhone screen to monitor your health

Tips for pinning the step counter to the iPhone screen to monitor your health

April 28, 2026
How to turn off password suggestions on iPhone: Prevent Safari from auto-filling passwords

How to turn off password suggestions on iPhone: Prevent Safari from auto-filling passwords

April 27, 2026
No Result
View All Result
  • Home
  • News
  • Software
  • Knowledge
  • MMO
  • Tips
  • Security
  • Network
  • Office

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