• 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

Creating a 2D Platformer Game with Godot]Part 7: Enemy Design

AnonyViet by AnonyViet
January 27, 2023
in Tips
0

Enemies or monsters are an indispensable thing in Platformer or Rpg games. So, in this part I will show you how to design an enemy and how the design will last 2 or 3 parts.

Join the channel Telegram of the AnonyViet 👉 Link 👈

Art

As for the Art part, you can download it via the au link: Desert Enemy Pixel Art Game CharactersCreating a 2D Platformer Game with Godot]Part 7: Enemy Design

After downloading, in Assets create a new folder called KeThu and copy all the art into it.

Create enemies

Create a new scene

Creating 2D Platformer Game with Godot]Part 7: Enemy Design 17

Like Player, you will create a kinematicbody and here I rename it Cao (that fox) and add 2 more child buttons, AnimatedSprt and CollisionShape2D.

Creating a 2D Platformer Game with Godot]Part 7: Enemy Design 18

You create new Frames in AnimatedSprite.

Creating 2D Platformer Game with Godot]Part 7: Enemy Design 19

Here I add 5 animations corresponding to art.

Creating 2D Platformer Game with Godot]Part 7: Enemy Design 20

This is after adding the animation and it shows up.

Creating a 2D Platformer Game with Godot]Part 7: Enemy Design 21

You add CollisioShape to it
Creating a 2D Platformer Game with Godot]Part 7: Enemy Design 22

Done then rotate CollisionShape2D to landscape.

Creating a 2D Platformer Game with Godot]Part 7: Enemy Design 23

Click on the toolbar to make adjustments.

Creating a 2D Platformer Game with Godot]Part 7: Enemy Design 24

Then adjust the AnimatedSprite to fit the CollisionShape2D.

Note: You always take the CollisionShape as the alignment point and don’t change the position or something of the CollisionShape .

Creating a 2D Platformer Game with Godot]Part 7: Enemy Design 25

Done then save the scene, I create a new folder in Scenes called Kethu and save it there.

More Scripts

Next is the code part.Creating a 2D Platformer Game with Godot]Part 7: Enemy Design 26

Creating a 2D Platformer Game with Godot]Part 7: Enemy Design 27

Add a little script.

extends KinematicBody2D


var tocdo = 60
var trongluc = 10
var chuyendong = Vector2()
var huong_dichuyen = 1
onready var animation = $AnimatedSprite

func _physics_process(delta):
    
    chuyendong.x = tocdo * huong_dichuyen
    chuyendong.y += trongluc
    chuyendong = move_and_slide(chuyendong,Vector2.UP)
    
    if is_on_wall():
        huong_dichuyen = huong_dichuyen * -1

Here, it is no different from Player as it needs 4 basic variables to be able to move and 1 variable to be able to use animation.

Change direction_dichuyen because this is AI so you don’t have to press the button to move it or anything, so I’ll set it to 1 by default.

At the function _physics_process(delta):

  • The first 3 lines are not far away
  • Current if is_on_wall() is a function that allows you to check if an enemy child is on the move and with whom it touches.
  • Below I will check if moving to the right meets a wall or something, it will turn to the left to move forward and vice versa.

Creating a 2D Platformer Game with Godot]Part 7: Enemy Design 28

Then you Instance the fox into the Map so you can see it has moved.

func _physics_process(delta):
    
    chuyendong.x = tocdo * huong_dichuyen
    chuyendong.y += trongluc
    chuyendong = move_and_slide(chuyendong,Vector2.UP)
    animation.play("dichuyen")
    
    if is_on_wall():
        huong_dichuyen = huong_dichuyen * -1
        scale.x = scale.y * huong_dichuyen

At the function _physics_process(): then I added 2 command lines to be able to run the animation and rotate the image left and right.Creating a 2D Platformer Game with Godot]Part 7: Enemy Design

This is the result.
Creating 2D Platformer Game with Godot]Part 7: Enemy Design 30

Sometimes the Sprite will be inverted and you can correct it by adjusting the Flip_H of the Sprite or AnimatedSprite.

Summary

So in this part you can already make the most basic enemy, in the next part I will show you how to make it move on the surface.

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

Tags: creatingDesignEnemyGameGodotPartPlatformer
Previous Post

What is a Brute Force Attack and How to Prevent it

Next Post

Create images with beautiful Numeric Characters

AnonyViet

AnonyViet

Related Posts

Windows 7/8.1/10 users will be upgraded to Windows 11 for free
Tips

Windows 7/8.1/10 users will be upgraded to Windows 11 for free

July 30, 2026
Instructions for receiving ChatGPT Plus for 1 month for free in 2026
Tips

Instructions for receiving ChatGPT Plus for 1 month for free in 2026

July 28, 2026
Some reasons I don’t like Windows 11
Tips

Some reasons I don’t like Windows 11

July 27, 2026
Instructions on how to get free Facebook white ticks
Tips

Instructions on how to get free Facebook white ticks

July 27, 2026
Collection of Windows 11 wallpapers for computers and phones
Tips

Collection of Windows 11 wallpapers for computers and phones

July 26, 2026
Don’t install leaked Windows 11
Tips

Don’t install leaked Windows 11

July 25, 2026
Next Post
Create images with beautiful Numeric Characters

Create images with beautiful Numeric Characters

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted

Recent News

Windows 7/8.1/10 users will be upgraded to Windows 11 for free

Windows 7/8.1/10 users will be upgraded to Windows 11 for free

July 30, 2026
Instructions for receiving the free Certified LLM Security Expert certificate

Instructions for receiving the free Certified LLM Security Expert certificate

July 30, 2026
MSI laptops are not just for gamers: Which line is suitable for students, office workers and creative people?

MSI laptops are not just for gamers: Which line is suitable for students, office workers and creative people?

July 29, 2026
What is quantum resistant cryptography? Why must the Internet change?

What is quantum resistant cryptography? Why must the Internet change?

July 29, 2026
Windows 7/8.1/10 users will be upgraded to Windows 11 for free

Windows 7/8.1/10 users will be upgraded to Windows 11 for free

July 30, 2026
Instructions for receiving the free Certified LLM Security Expert certificate

Instructions for receiving the free Certified LLM Security Expert certificate

July 30, 2026
MSI laptops are not just for gamers: Which line is suitable for students, office workers and creative people?

MSI laptops are not just for gamers: Which line is suitable for students, office workers and creative people?

July 29, 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

Windows 7/8.1/10 users will be upgraded to Windows 11 for free

Windows 7/8.1/10 users will be upgraded to Windows 11 for free

July 30, 2026
Instructions for receiving the free Certified LLM Security Expert certificate

Instructions for receiving the free Certified LLM Security Expert certificate

July 30, 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