Player changes + projectile fixes
This commit is contained in:
+30
-18
@@ -143,29 +143,41 @@ func _process(_delta):
|
||||
|
||||
func set_aim_angle(angle: float):
|
||||
aim_angle = angle
|
||||
|
||||
# Update facing direction based on aim angle
|
||||
# Convert angle to direction (down, up, left, right)
|
||||
var deg = rad_to_deg(angle)
|
||||
if deg < 0:
|
||||
deg += 360
|
||||
|
||||
if deg >= 315 or deg < 45:
|
||||
current_direction = "right"
|
||||
elif deg >= 45 and deg < 135:
|
||||
current_direction = "down"
|
||||
elif deg >= 135 and deg < 225:
|
||||
current_direction = "left"
|
||||
else:
|
||||
current_direction = "up"
|
||||
# Don't update direction from aim - only update from movement
|
||||
|
||||
func _update_walk_animation():
|
||||
if not animated_sprite or not animated_sprite.sprite_frames:
|
||||
return
|
||||
|
||||
var anim_name = "walk_" + current_direction
|
||||
if animated_sprite.animation != anim_name:
|
||||
animated_sprite.play(anim_name)
|
||||
# Update direction based on movement vector
|
||||
if move_direction.length() > 0.1:
|
||||
# Player is moving, update direction based on movement
|
||||
var angle = move_direction.angle()
|
||||
var deg = rad_to_deg(angle)
|
||||
if deg < 0:
|
||||
deg += 360
|
||||
|
||||
if deg >= 315 or deg < 45:
|
||||
current_direction = "right"
|
||||
elif deg >= 45 and deg < 135:
|
||||
current_direction = "down"
|
||||
elif deg >= 135 and deg < 225:
|
||||
current_direction = "left"
|
||||
else:
|
||||
current_direction = "up"
|
||||
|
||||
# Play walk animation for current direction (will loop)
|
||||
var anim_name = "walk_" + current_direction
|
||||
if animated_sprite.animation != anim_name and not is_attacking:
|
||||
animated_sprite.play(anim_name)
|
||||
else:
|
||||
# Player stopped moving - show idle frame (frame 0 of walk animation)
|
||||
if not is_attacking:
|
||||
var anim_name = "walk_" + current_direction
|
||||
if animated_sprite.animation != anim_name or animated_sprite.is_playing():
|
||||
animated_sprite.play(anim_name)
|
||||
animated_sprite.pause()
|
||||
animated_sprite.frame = 0 # Show first frame as idle
|
||||
|
||||
func play_attack_animation(weapon_type: String = "fist"):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user