• 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

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
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

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