Dog now watches target
This commit is contained in:
parent
4e2f51f50f
commit
4834ebdda8
3 changed files with 50 additions and 1 deletions
|
|
@ -4,12 +4,36 @@ class_name Dog
|
|||
@onready var death_box = $DeathBox
|
||||
|
||||
var acquired_target : Bee = null
|
||||
var target_timer : float = 0.0
|
||||
|
||||
func _ready():
|
||||
death_box.connect("body_entered", Callable(self, "_on_body_entered"))
|
||||
death_box.connect("body_exited", Callable(self, "_on_body_exited"))
|
||||
|
||||
func _process(delta):
|
||||
if acquired_target:
|
||||
target_timer += delta
|
||||
|
||||
# Look at the target
|
||||
rotation = lerp_angle(rotation, rotation + get_angle_to(acquired_target.global_position), 0.25)
|
||||
|
||||
if target_timer > 3.0:
|
||||
# Kill the target!
|
||||
acquired_target.die()
|
||||
acquired_target = null
|
||||
target_timer = 0.0
|
||||
return
|
||||
|
||||
|
||||
func _on_body_entered(area):
|
||||
if area.is_in_group("bee"):
|
||||
if !acquired_target:
|
||||
Log.pr("Acquired target")
|
||||
target_timer = 0.0
|
||||
acquired_target = area
|
||||
|
||||
func _on_body_exited(area):
|
||||
if area == acquired_target:
|
||||
Log.pr("Lost target")
|
||||
acquired_target = null
|
||||
target_timer = 0.0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=14 format=3 uid="uid://mk5n0hrwk4yi"]
|
||||
[gd_scene load_steps=15 format=3 uid="uid://mk5n0hrwk4yi"]
|
||||
|
||||
[ext_resource type="Script" path="res://scenes/scripts/test_level.gd" id="1_lgt1m"]
|
||||
[ext_resource type="PackedScene" uid="uid://dyu4mucawjlu6" path="res://entities/Beehive.tscn" id="2_5ueyo"]
|
||||
|
|
@ -11,6 +11,7 @@
|
|||
[ext_resource type="PackedScene" uid="uid://b7eeptlk47ymd" path="res://ui/UiComponent.tscn" id="6_xuemm"]
|
||||
[ext_resource type="PackedScene" uid="uid://cwutwy11pityw" path="res://ui/LevelCompleteComponent.tscn" id="8_4k5cm"]
|
||||
[ext_resource type="Script" path="res://ui/scripts/level_complete_component.gd" id="9_qrlto"]
|
||||
[ext_resource type="AudioStream" uid="uid://bgcbd6xf0lyrr" path="res://resources/music/bee_background.ogg" id="12_5cn5j"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_usqp5"]
|
||||
radius = 142.316
|
||||
|
|
@ -140,6 +141,11 @@ offset_right = 1280.0
|
|||
offset_bottom = 720.0
|
||||
script = ExtResource("9_qrlto")
|
||||
|
||||
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
|
||||
stream = ExtResource("12_5cn5j")
|
||||
volume_db = -18.0
|
||||
autoplay = true
|
||||
|
||||
[connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnDirector" to="DroneManager" method="_on_spawn_director_pressed"]
|
||||
[connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnCollector" to="DroneManager" method="_on_spawn_collector_pressed"]
|
||||
[connection signal="pressed" from="DroneManager/Control/MarginContainer/DroneControls/SpawnDistractor" to="DroneManager" method="_on_spawn_distractor_pressed"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue