fx: attacking sprite/logic mismatch
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var attack_duration = 0.12 # TODO: finetune
|
||||
@export var attack_duration = 0.2 # TODO: finetune
|
||||
@export var attack_cooldown_duration = 0.4
|
||||
|
||||
@onready var attack_area: Area2D = $AttackArea
|
||||
@@ -19,6 +19,8 @@ func _ready() -> void:
|
||||
attack_area.monitoring = false # no collision until attacking
|
||||
attack_timer.wait_time = attack_duration
|
||||
attack_cooldown_timer.wait_time = attack_cooldown_duration
|
||||
|
||||
|
||||
|
||||
func _process(delta):
|
||||
velocity = Vector2.ZERO
|
||||
@@ -53,16 +55,21 @@ func attack() -> void:
|
||||
|
||||
func _on_attack_timeout() -> void:
|
||||
attack_area.monitoring = false
|
||||
sprite.play("default")
|
||||
attack_cooldown_timer.start()
|
||||
|
||||
func _on_cooldown_timeout() -> void:
|
||||
can_attack = true
|
||||
sprite.play("default")
|
||||
|
||||
func _on_attack_hit(body: Node2D) -> void:
|
||||
var hit_hittable = false
|
||||
if body.is_in_group("prey") or body.is_in_group("predators"):
|
||||
if body.has_method("handle_damage"):
|
||||
body.handle_damage(damage)
|
||||
hit_hittable = true
|
||||
elif body.is_in_group("resources"):
|
||||
pass
|
||||
if hit_hittable:
|
||||
await get_tree().create_timer(0.2).timeout
|
||||
sprite.play("default")
|
||||
# TODO: resource handling logic
|
||||
|
||||
Reference in New Issue
Block a user