• 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

5+ prompts to create sparkling Christmas photos for mothers and babies at home
Tips

5+ prompts to create sparkling Christmas photos for mothers and babies at home

December 17, 2025
How to Clean Up Your Computer to Speed ​​Up Windows Faster
Tips

How to Clean Up Your Computer to Speed ​​Up Windows Faster

December 16, 2025
Share Snowfall Code for Website to celebrate Christmas
Tips

Share Snowfall Code for Website to celebrate Christmas

December 16, 2025
How to build web applications in just minutes with Youware
Tips

How to build web applications in just minutes with Youware

December 15, 2025
5 Free Adobe Illustrator Alternatives on Linux
Tips

5 Free Adobe Illustrator Alternatives on Linux

December 15, 2025
Review of Chongluadao utility – HieuPC’s new anti-fraud utility
Tips

Review of Chongluadao utility – HieuPC’s new anti-fraud utility

December 14, 2025
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

5+ prompts to create sparkling Christmas photos for mothers and babies at home

5+ prompts to create sparkling Christmas photos for mothers and babies at home

December 17, 2025
How to Clean Up Your Computer to Speed ​​Up Windows Faster

How to Clean Up Your Computer to Speed ​​Up Windows Faster

December 16, 2025
Share Snowfall Code for Website to celebrate Christmas

Share Snowfall Code for Website to celebrate Christmas

December 16, 2025
How to build web applications in just minutes with Youware

How to build web applications in just minutes with Youware

December 15, 2025
5+ prompts to create sparkling Christmas photos for mothers and babies at home

5+ prompts to create sparkling Christmas photos for mothers and babies at home

December 17, 2025
How to Clean Up Your Computer to Speed ​​Up Windows Faster

How to Clean Up Your Computer to Speed ​​Up Windows Faster

December 16, 2025
Share Snowfall Code for Website to celebrate Christmas

Share Snowfall Code for Website to celebrate Christmas

December 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

5+ prompts to create sparkling Christmas photos for mothers and babies at home

5+ prompts to create sparkling Christmas photos for mothers and babies at home

December 17, 2025
How to Clean Up Your Computer to Speed ​​Up Windows Faster

How to Clean Up Your Computer to Speed ​​Up Windows Faster

December 16, 2025
  • Home
  • Home 2
  • Home 3
  • Home 4
  • Home 5
  • Home 6
  • Next Dest Page
  • Sample Page

trang chủ f168 nhà cái 78win https://www.qq8827.com/ https://go99.ae.org/ https://nohu90.bid/

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

trang chủ f168 nhà cái 78win https://www.qq8827.com/ https://go99.ae.org/ https://nohu90.bid/

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