https://www.youtube.com/watch?v=9u59U-DWNJs&t=305s
How to Create an ENEMY In Godot 4In this video we are going to go over how to create an enemy in godot 4, An enemy is one of the most important things in a game, if you dont have smooth good...www.youtube.comhttps://kidscancode.org/godot_recipes/4.x/ai/chasing/index.html
ํด๋น ๊ฐ์ข ์ฐธ๊ณ ํ์ต๋๋ค.
๋ค์์ ์ ์ฝ๋ ์ ๋๋ค.
extends CharacterBody2D
var run_speed = 50
var player = null
func _physics_process(delta):
velocity = Vector2.ZERO
if player:
velocity = position.direction_to(player.position) * run_speed
move_and_slide()
func _on_detection_area_body_entered(body):
player = body
func _on_detection_area_body_exited(body):
player = null
==================================================================================================
ํผ์ ํด๊ฒฐํ์ต๋๋ค.
position -> global_position์ผ๋ก ๋ณ๊ฒฝํ๋๊น ๋ฐ๋ผ์ค๋ค์.
์๋ง ์ธ์คํด์คํ ์ดํ์ position์ ์ฌ์ฉํ ๊ฒ ๋๋ฌธ์ ์ ๋ฐ ํ์์ด ์๊ธด ๊ฒ ๊ฐ์ต๋๋ค.
๋๊ธ 0