• 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 11: Raycast2D Enemy in Godot – Part 2

AnonyViet by AnonyViet
July 15, 2024
in Tips
0

In this post I will guide you to create raycast2D so that enemies can move on the terrain as shown below without falling down. And let's get started.

Join the channel Telegram belong to AnonyViet 👉 Link 👈

[Lập trình game] Lesson 11: Raycast2D Enemy in Godot – Part 2

RAYCAST2D

Raycast2D Enemy Programming

Here Raycast 2D is a node: Query the object intersecting the ray means Raycast 2D is a ray and this ray is used to query the object when intersecting with the ray

ENEMY

Next is the enemy you enter the enemy's scene

Find yourself raycast2D

Raycast2D

And like this

Raycast2D code

Here you don't use the mouse but use the right arrow key to move it to the edge. collsionshape

And almost exposed like me

[Lập trình game]  Lesson 11: Raycast2D Enemy in Godot Part 2

On the properties side pay attention to yourself Enable and Cast to

live Enabled You click to choose for yourself and raycast will be green

[Lập trình game]  Lesson 11: Raycast2D Enemy in Godot Part 2

LIVE cast to part y you cast it near the enemy

[Lập trình game]  Lesson 11: Raycast2D Enemy in Godot Part 2

As in the picture, this enemy is too small so I will adjust the scale. raycast wall 0.5, 0.5

And after adjusting the scale, you also have to adjust the other parts.

[Lập trình game]  Lesson 11: Raycast2D Enemy in Godot Part 2

Next we will code for it.

And Coding for me

Below if is_on_wall

You add for me is

if $Raycast2D.is_collding == false:

vitri = vitri * -1

Here $Raycat2D is to call raycast2d || is_collecting is the command: Returns whether any object is intersecting the vector ray but here we set = false which means it will not intersect with anything.

And vitri = vitri * -1 here means the enemy will move backwards when on the terrain that I mentioned at the beginning of the article

And you notice when it has moved back, this raycast2D does not move back anymore, so we need to adjust it.

You add $RayCast2D.position.x *= -1 enter if is_on_wall and raycast collection Please

This is the command to help Raycast 2D can be redirected and you can apply it to other nodes like collsionshape etc.

It is done

And remember to delete *delta let's go

If the code does not run, use the code below.

Full code godot Raycast2D

Previous Post

Google Jamboard: Interactive whiteboard for effective teamwork

Next Post

How to Create Hyper-Realistic Videos from Photos with Luma Dream Machine

AnonyViet

AnonyViet

Related Posts

Cách Đăng ký Nhận Code ChatGPT Business
Tips

Cách Đăng ký Nhận Code ChatGPT Business

November 2, 2026
Instructions for cleaning LG TV with Antigravity to help it run faster
Tips

Instructions for cleaning LG TV with Antigravity to help it run faster

October 30, 2026
Quét lỗ hổng bảo mật cho Vide Coding bằng Security Audit Skill
Tips

Quét lỗ hổng bảo mật cho Vide Coding bằng Security Audit Skill

October 27, 2026
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
Next Post
How to Create Hyper-Realistic Videos from Photos with Luma Dream Machine

How to Create Hyper-Realistic Videos from Photos with Luma Dream Machine

0 0 votes
Article Rating
Subscribe
Login
Notify of
guest

guest

0 Comments
Oldest
Newest Most Voted

Recent News

Instructions on how to buy super bargain 1k Bach Hoa Xanh products

Instructions on how to buy super bargain 1k Bach Hoa Xanh products

November 6, 2026
Besides the 7500 mAh battery and 6.9 inch screen, what else does the POCO C95 Pro 4G have to make it a secondary device worth buying?

Besides the 7500 mAh battery and 6.9 inch screen, what else does the POCO C95 Pro 4G have to make it a secondary device worth buying?

November 5, 2026
App fixes printer errors automatically, effective immediately with 1 click

App fixes printer errors automatically, effective immediately with 1 click

November 5, 2026
What to do when your company opening information is stolen?

What to do when your company opening information is stolen?

November 4, 2026
Instructions on how to buy super bargain 1k Bach Hoa Xanh products

Instructions on how to buy super bargain 1k Bach Hoa Xanh products

November 6, 2026
Besides the 7500 mAh battery and 6.9 inch screen, what else does the POCO C95 Pro 4G have to make it a secondary device worth buying?

Besides the 7500 mAh battery and 6.9 inch screen, what else does the POCO C95 Pro 4G have to make it a secondary device worth buying?

November 5, 2026
App fixes printer errors automatically, effective immediately with 1 click

App fixes printer errors automatically, effective immediately with 1 click

November 5, 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

Instructions on how to buy super bargain 1k Bach Hoa Xanh products

Instructions on how to buy super bargain 1k Bach Hoa Xanh products

November 6, 2026
Besides the 7500 mAh battery and 6.9 inch screen, what else does the POCO C95 Pro 4G have to make it a secondary device worth buying?

Besides the 7500 mAh battery and 6.9 inch screen, what else does the POCO C95 Pro 4G have to make it a secondary device worth buying?

November 5, 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