• 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 2D Platformer Game with Godot]Part 7: Enemy Design 29

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

Top 5 game programming languages ​​to learn now
Tips

Top 5 game programming languages ​​to learn now

June 8, 2025
[Godot Shooter] #2: Creating characters & shooting bullets
Tips

[Godot Shooter] #2: Creating characters & shooting bullets

June 7, 2025
What do you need to learn game programming? Is it difficult? How long does it take?
Tips

What do you need to learn game programming? Is it difficult? How long does it take?

June 6, 2025
Instructions for registering chatgpt team at $ 1
Tips

Instructions for registering chatgpt team at $ 1

June 5, 2025
How to engrave the right mouse menu error on Windows
Tips

How to engrave the right mouse menu error on Windows

June 5, 2025
How to create online meme photos is very easy with a few steps
Tips

How to create online meme photos is very easy with a few steps

June 5, 2025
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
Inline Feedbacks
View all comments

Recent News

Top 5 game programming languages ​​to learn now

Top 5 game programming languages ​​to learn now

June 8, 2025
The iPhone list is updated with iOS 26

The iPhone list is updated with iOS 26

June 8, 2025
Discover the glowing effect next to the iPhone ios 18 screen

Discover the glowing effect next to the iPhone ios 18 screen

June 8, 2025
[Godot Shooter] #2: Creating characters & shooting bullets

[Godot Shooter] #2: Creating characters & shooting bullets

June 7, 2025
Top 5 game programming languages ​​to learn now

Top 5 game programming languages ​​to learn now

June 8, 2025
The iPhone list is updated with iOS 26

The iPhone list is updated with iOS 26

June 8, 2025
Discover the glowing effect next to the iPhone ios 18 screen

Discover the glowing effect next to the iPhone ios 18 screen

June 8, 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

Top 5 game programming languages ​​to learn now

Top 5 game programming languages ​​to learn now

June 8, 2025
The iPhone list is updated with iOS 26

The iPhone list is updated with iOS 26

June 8, 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í SHBET https://kubet88.yoga/ bj88

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í SHBET https://kubet88.yoga/ bj88

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