ft (placeholder): player attacking anim

This commit is contained in:
2026-01-17 14:47:16 +01:00
parent 03117b77fb
commit c0f5dd4628
4 changed files with 56 additions and 3 deletions

View File

@@ -6,6 +6,7 @@ extends CharacterBody2D
@onready var attack_area: Area2D = $AttackArea
@onready var attack_timer: Timer = $AttackTimer
@onready var attack_cooldown_timer: Timer = $AttackCooldownTimer
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
@export var speed = 200
var damage = 10
@@ -32,6 +33,9 @@ func _process(delta):
if Input.is_action_pressed("try_attack"):
try_attack()
if not velocity.is_zero_approx():
look_at(velocity * 1000000) # FIXME: ideally we look_at a point at infinity
# or rotate the player some other way
move_and_collide(speed * velocity * delta)
#position += speed * velocity * delta
position = GameManager.get_boundaried_position(position)
@@ -45,7 +49,7 @@ func attack() -> void:
can_attack = false
attack_area.monitoring = true
attack_timer.start()
# TODO: attack animation+sound+etc
sprite.play("attacking")
func _on_attack_timeout() -> void:
attack_area.monitoring = false
@@ -53,6 +57,7 @@ func _on_attack_timeout() -> void:
func _on_cooldown_timeout() -> void:
can_attack = true
sprite.play("default")
func _on_attack_hit(body: Node2D) -> void:
if body.is_in_group("prey") or body.is_in_group("predators"):