game: add rat enemy
This commit is contained in:
@@ -6,6 +6,7 @@ extends CharacterBody2D
|
||||
@export var default_contact_damage: float = 0.0
|
||||
@export var target_distance: float = 6.0
|
||||
@export var path_update_interval: float = 1.5
|
||||
@export var xp_dropped: float = 5.0
|
||||
|
||||
@onready var target_cast: RayCast2D = $TargetCast
|
||||
@onready var animation_player: AnimationPlayer = $AnimationPlayer
|
||||
@@ -97,7 +98,7 @@ func _do_nav_agent_movement():
|
||||
func check_contact_damage():
|
||||
if default_contact_damage == 0.0:
|
||||
return
|
||||
if global_position.distance_to(target.global_position) > target_distance:
|
||||
if global_position.distance_to(target.global_position) > target_distance + 2:
|
||||
return
|
||||
deal_contact_damage()
|
||||
|
||||
@@ -140,7 +141,7 @@ func die():
|
||||
|
||||
func drop_xp_orb() -> void:
|
||||
var orb: XPOrb = preload("res://scenes/xp_orb.tscn").instantiate()
|
||||
orb.value = 5
|
||||
orb.value = xp_dropped
|
||||
orb.position = position
|
||||
get_parent().call_deferred("add_child", orb)
|
||||
|
||||
|
Reference in New Issue
Block a user