extends CharacterBody2D
@onready var sprite = $AnimationPlayer
@onready var joystick = $"../joystick"
var speed = 300
var walk_animations = [
"a",
"b",
"c",
"d",
"e",
"f",
"g",
"h"
]
var current_animation = "idle"
func _physics_process(delta):
var direction = joystick.posVector
var animation_index = direction.angle() / (PI / 4)
if animation_index < 0:
animation_index += 8
current_animation = walk_animations[animation_index]
if direction:
velocity = direction * speed
else:
velocity = Vector2(0, 0)
current_animation = "idle"
sprite.play(current_animation)
move_and_slide()
๋ฆฌํ ์ค๊ฑฐ make this into 4 direction movement
๊ฒฐ๊ณผ
func _physics_process(delta):
var direction = joystick.posVector
var animation_index = direction.angle() / (PI / 2)
if direction.length() > 0:
current_animation = walk_animations[animation_index]
velocity = direction.normalized() * speed
else:
current_animation = "idle"
velocity = Vector2.ZERO
sprite.play(current_animation)
move_and_slide(velocity)
๋ญํ๋
ธ
๋๋ ์ธ์ด๋ฅผ ๋ฌ๋ผ๋๊น
๋ง์ ๊ฒ์ ๋ง๋๋ ค๋ฉด ์์ ํด์ผ ๋๋
์ธ์ด๋ฅผ ์ฃผ๋ค
๋๊ฐ ๊ตฌ๊ธ ai ๋ณด๋ค ๋ชปํ๋ฉด ๋ชปํ๋ค๋๊ฒ ์ฆ๋ช
๋จ
๊ตฌ๊ธ bard์ ๋ฌผ์ด๋ณธ๋ค๋ฉด
๋ฌด์จ ๊ตฌ๊ธ bard ๋ด๊ฐ ์ฒ์ ์จ๋ดค์ ๋
๋น์ ์ฑ๋ฅ์ด๋ค ์ฝํ์ผ๋ฟ ์ด๊ฑฐ๋
- dc official App
๊ทธ๋ฆฌ๊ณ ๋ญฃ๋ ๋ชจ๋ฅด๋ฉด์ ๋๊ธ๋ก ์ฒ ์์งํ๋ ์ ๋ค์ ๊ทธ๋๊น ๋๊ฐ ๋ ์ธ์ ์ฌ๋๊ฑฐ๋ค - dc App
์.. ๊ณ ๋ ํ์ดํ !
๊ณ ๋ ๋ถ๋ค ์ด ์ฝ๋ ํฐ๋ง ๋จน๊ณ ๊ณต๊ฐํ๊ฑด๋ฐ ๋ชจ๋ฐ์ผ ์กฐ์ด์คํฑ์ผ๋ก 8์ ๋ฐฉํฅ ๊ตฌํ์ด์์ - dc App
์ด๋ ๋ฐฉํฅ์ ๋ฐ๋ฅธ ์ ๋๋ฉ์ด์ ๋ ์น์ ๊ณ ๋ ํ์ดํ ! - dc App