added dog distractions
This commit is contained in:
parent
4834ebdda8
commit
51af0ea751
11 changed files with 117 additions and 5 deletions
|
|
@ -5,6 +5,7 @@ class_name Dog
|
|||
|
||||
var acquired_target : Bee = null
|
||||
var target_timer : float = 0.0
|
||||
var distracted : bool = false
|
||||
|
||||
func _ready():
|
||||
death_box.connect("body_entered", Callable(self, "_on_body_entered"))
|
||||
|
|
@ -26,14 +27,23 @@ func _process(delta):
|
|||
|
||||
|
||||
func _on_body_entered(area):
|
||||
if area.is_in_group("bee"):
|
||||
if area.is_in_group("bee") and distracted == false:
|
||||
if !acquired_target:
|
||||
Log.pr("Acquired target")
|
||||
target_timer = 0.0
|
||||
acquired_target = area
|
||||
|
||||
if area.is_in_group("distractor"):
|
||||
Log.pr("Distracted")
|
||||
acquired_target = null
|
||||
distracted = true
|
||||
|
||||
func _on_body_exited(area):
|
||||
if area == acquired_target:
|
||||
Log.pr("Lost target")
|
||||
acquired_target = null
|
||||
target_timer = 0.0
|
||||
|
||||
if area.is_in_group("distractor"):
|
||||
Log.pr("No longer distracted")
|
||||
distracted = false
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue