Adds enemies
This commit is contained in:
parent
cf8ba8bacb
commit
76e5b1927f
324 changed files with 28447 additions and 106 deletions
88
demo/ai/trees/01_agent_melee_simple.tres
Normal file
88
demo/ai/trees/01_agent_melee_simple.tres
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=21 format=3 uid="uid://bpdm5jnegi38"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_2jpsu"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="2_h5db5"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="3_bpmfp"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_nrd4b"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qiw21"]
|
||||
animation_player = SubResource("BBNode_nrd4b")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_xlud8"]
|
||||
min_duration = 0.7
|
||||
max_duration = 1.5
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_yhjh1"]
|
||||
custom_name = "Pause before action"
|
||||
children = [SubResource("BTPlayAnimation_qiw21"), SubResource("BTRandomWait_xlud8")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_wpj6d"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_olf37"]
|
||||
animation_player = SubResource("BBNode_wpj6d")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_ulbrf"]
|
||||
script = ExtResource("1_2jpsu")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_a4jqi"]
|
||||
script = ExtResource("2_h5db5")
|
||||
target_var = &"target"
|
||||
speed_var = &"speed"
|
||||
approach_distance = 100.0
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_xek5v"]
|
||||
time_limit = 2.0
|
||||
children = [SubResource("BTAction_a4jqi")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_1xfnq"]
|
||||
custom_name = "Pursue player"
|
||||
children = [SubResource("BTPlayAnimation_olf37"), SubResource("BTAction_ulbrf"), SubResource("BTTimeLimit_xek5v")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_kidxn"]
|
||||
script = ExtResource("3_bpmfp")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_tadkc"]
|
||||
duration = 0.1
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_s8evu"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_ppmxd"]
|
||||
await_completion = 2.0
|
||||
animation_player = SubResource("BBNode_s8evu")
|
||||
animation_name = &"attack_1"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_ww5v2"]
|
||||
custom_name = "Melee attack"
|
||||
children = [SubResource("BTAction_kidxn"), SubResource("BTWait_tadkc"), SubResource("BTPlayAnimation_ppmxd")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_pxl2k"]
|
||||
children = [SubResource("BTSequence_yhjh1"), SubResource("BTSequence_1xfnq"), SubResource("BTSequence_ww5v2")]
|
||||
|
||||
[resource]
|
||||
description = "Welcome to the [b]LimboAI[/b] demo project! This demo project consists of three parts:
|
||||
- If you're new to behavior trees, you can access the [b]Tutorial[/b] by clicking the \"Begin Tutorial\" button on the toolbar.
|
||||
- To experience the demo game, just click the \"Switch to Game\" button.
|
||||
- On this screen, you can inspect the AI behavior tree in action for each agent in the game."
|
||||
blackboard_plan = SubResource("BlackboardPlan_46tbn")
|
||||
root_task = SubResource("BTSequence_pxl2k")
|
||||
120
demo/ai/trees/02_agent_charger.tres
Normal file
120
demo/ai/trees/02_agent_charger.tres
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=28 format=3 uid="uid://ylife72ym5et"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_657p6"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_flanking_pos.gd" id="2_t3udh"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="3_u2ra5"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="4_xwjl7"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/move_forward.gd" id="5_ucvak"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_qd806"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
var/charge_speed/name = &"charge_speed"
|
||||
var/charge_speed/type = 3
|
||||
var/charge_speed/value = 1000.0
|
||||
var/charge_speed/hint = 1
|
||||
var/charge_speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_yrurg"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_ha2ag"]
|
||||
animation_player = SubResource("BBNode_yrurg")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_cedqr"]
|
||||
max_duration = 3.0
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_l3v31"]
|
||||
custom_name = "Short break"
|
||||
children = [SubResource("BTPlayAnimation_ha2ag"), SubResource("BTRandomWait_cedqr")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_pp23y"]
|
||||
script = ExtResource("1_657p6")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_pmvd0"]
|
||||
script = ExtResource("2_t3udh")
|
||||
target_var = &"target"
|
||||
flank_side = 0
|
||||
range_min = 500
|
||||
range_max = 600
|
||||
position_var = &"flank_pos"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_xh3wr"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_h0poo"]
|
||||
animation_player = SubResource("BBNode_xh3wr")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_87mi0"]
|
||||
script = ExtResource("3_u2ra5")
|
||||
target_position_var = &"flank_pos"
|
||||
speed_var = &"speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &""
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_is5ag"]
|
||||
time_limit = 3.0
|
||||
children = [SubResource("BTAction_87mi0")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_p6pgg"]
|
||||
custom_name = "Flank target"
|
||||
children = [SubResource("BTAction_pp23y"), SubResource("BTAction_pmvd0"), SubResource("BTPlayAnimation_h0poo"), SubResource("BTTimeLimit_is5ag")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_q5g4a"]
|
||||
script = ExtResource("4_xwjl7")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_bfijg"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_4okoy"]
|
||||
await_completion = 2.0
|
||||
animation_player = SubResource("BBNode_bfijg")
|
||||
animation_name = &"charge_prepare"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_ovu3r"]
|
||||
duration = 0.6
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_mde2g"]
|
||||
custom_name = "Anticipation"
|
||||
children = [SubResource("BTAction_q5g4a"), SubResource("BTPlayAnimation_4okoy"), SubResource("BTWait_ovu3r")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_kpp70"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_8s1wq"]
|
||||
animation_player = SubResource("BBNode_kpp70")
|
||||
animation_name = &"charge"
|
||||
blend = 0.05
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_o18uk"]
|
||||
script = ExtResource("5_ucvak")
|
||||
speed_var = &"charge_speed"
|
||||
duration = 1.5
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_8lur1"]
|
||||
custom_name = "Charge!"
|
||||
children = [SubResource("BTPlayAnimation_8s1wq"), SubResource("BTAction_o18uk")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_pjuov"]
|
||||
custom_name = "Charge Attack"
|
||||
children = [SubResource("BTSequence_l3v31"), SubResource("BTSequence_p6pgg"), SubResource("BTSequence_mde2g"), SubResource("BTSequence_8lur1")]
|
||||
|
||||
[resource]
|
||||
description = "A [dec]Decorator[/dec] is a type of task that typically has only one child. Decorators are commonly used to alter the behavior or status of their child task. In this behavior tree, the [dec]TimeLimit[/dec] decorator sets a maximum time for the [act]Arrive[/act] action to complete its work. If the child task exceeds this time limit without finishing, it will be aborted, and the TimeLimit decorator will return [FAILURE]."
|
||||
blackboard_plan = SubResource("BlackboardPlan_qd806")
|
||||
root_task = SubResource("BTSequence_pjuov")
|
||||
120
demo/ai/trees/03_agent_imp.tres
Normal file
120
demo/ai/trees/03_agent_imp.tres
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=30 format=3 uid="uid://c2bxoo68ywb27"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_random_nearby_pos.gd" id="1_cdtqu"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="2_31fsn"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="3_y1r1a"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="4_jlgat"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="5_o4ggh"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_3y70b"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_klk26"]
|
||||
animation_player = SubResource("BBNode_3y70b")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_chmiy"]
|
||||
script = ExtResource("1_cdtqu")
|
||||
range_min = 200.0
|
||||
range_max = 500.0
|
||||
position_var = &"pos"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_5kivl"]
|
||||
script = ExtResource("2_31fsn")
|
||||
target_position_var = &"pos"
|
||||
speed_var = &"speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &""
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_k184c"]
|
||||
custom_name = "Chaotic Walk"
|
||||
children = [SubResource("BTPlayAnimation_klk26"), SubResource("BTAction_chmiy"), SubResource("BTAction_5kivl")]
|
||||
|
||||
[sub_resource type="BTProbability" id="BTProbability_ifsry"]
|
||||
children = [SubResource("BTSequence_k184c")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_nrd4b"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qiw21"]
|
||||
animation_player = SubResource("BBNode_nrd4b")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_xlud8"]
|
||||
min_duration = 0.7
|
||||
max_duration = 1.5
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_n5ltc"]
|
||||
custom_name = "Pause before action"
|
||||
children = [SubResource("BTPlayAnimation_qiw21"), SubResource("BTRandomWait_xlud8")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_wpj6d"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_olf37"]
|
||||
animation_player = SubResource("BBNode_wpj6d")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_ulbrf"]
|
||||
script = ExtResource("3_y1r1a")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_a4jqi"]
|
||||
script = ExtResource("4_jlgat")
|
||||
target_var = &"target"
|
||||
speed_var = &"speed"
|
||||
approach_distance = 100.0
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_xek5v"]
|
||||
time_limit = 2.0
|
||||
children = [SubResource("BTAction_a4jqi")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_1xfnq"]
|
||||
custom_name = "Pursue player"
|
||||
children = [SubResource("BTPlayAnimation_olf37"), SubResource("BTAction_ulbrf"), SubResource("BTTimeLimit_xek5v")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_kidxn"]
|
||||
script = ExtResource("5_o4ggh")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_tadkc"]
|
||||
duration = 0.1
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_s8evu"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_ppmxd"]
|
||||
await_completion = 2.0
|
||||
animation_player = SubResource("BBNode_s8evu")
|
||||
animation_name = &"attack_1"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_ww5v2"]
|
||||
custom_name = "Melee attack"
|
||||
children = [SubResource("BTAction_kidxn"), SubResource("BTWait_tadkc"), SubResource("BTPlayAnimation_ppmxd")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_pxl2k"]
|
||||
custom_name = "Engage player"
|
||||
children = [SubResource("BTSequence_n5ltc"), SubResource("BTSequence_1xfnq"), SubResource("BTSequence_ww5v2")]
|
||||
|
||||
[sub_resource type="BTSelector" id="BTSelector_y3llm"]
|
||||
children = [SubResource("BTProbability_ifsry"), SubResource("BTSequence_pxl2k")]
|
||||
|
||||
[resource]
|
||||
description = "Here, the [dec]Probability[/dec] decorator allows the execution of its branch in 50% of cases. This introduces a slight variation to the behavior each time the [comp]Chaotic walk[/comp] sequence is considered by the [comp]Selector[/comp]. This sequence can be selected several times in a row as long as the Probability decorator permits it. The [comp]Engage player[/comp] sequence is only executed if Probability returns [FAILURE]."
|
||||
blackboard_plan = SubResource("BlackboardPlan_46tbn")
|
||||
root_task = SubResource("BTSelector_y3llm")
|
||||
190
demo/ai/trees/04_agent_skirmisher.tres
Normal file
190
demo/ai/trees/04_agent_skirmisher.tres
Normal file
|
|
@ -0,0 +1,190 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=44 format=3 uid="uid://qqmjvbeibatn"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_2883n"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_flanking_pos.gd" id="2_cjso2"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="2_lpckh"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="3_treio"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="4_57x51"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/in_range.gd" id="5_p5dih"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/back_away.gd" id="6_fkv0k"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
var/fast_speed/name = &"fast_speed"
|
||||
var/fast_speed/type = 3
|
||||
var/fast_speed/value = 600.0
|
||||
var/fast_speed/hint = 1
|
||||
var/fast_speed/hint_string = "10,1000,10"
|
||||
var/slow_speed/name = &"slow_speed"
|
||||
var/slow_speed/type = 3
|
||||
var/slow_speed/value = 300.0
|
||||
var/slow_speed/hint = 1
|
||||
var/slow_speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_ulbrf"]
|
||||
script = ExtResource("1_2883n")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_nrd4b"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qiw21"]
|
||||
animation_player = SubResource("BBNode_nrd4b")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_xlud8"]
|
||||
min_duration = 2.0
|
||||
max_duration = 3.0
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_yhjh1"]
|
||||
custom_name = "Summoning sickness"
|
||||
children = [SubResource("BTAction_ulbrf"), SubResource("BTPlayAnimation_qiw21"), SubResource("BTRandomWait_xlud8")]
|
||||
|
||||
[sub_resource type="BTRunLimit" id="BTRunLimit_tq3e1"]
|
||||
children = [SubResource("BTSequence_yhjh1")]
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_uk4dg"]
|
||||
script = ExtResource("5_p5dih")
|
||||
distance_min = 0.0
|
||||
distance_max = 300.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_7c0g0"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_sty80"]
|
||||
animation_player = SubResource("BBNode_7c0g0")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
speed = 1.2
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_jryg6"]
|
||||
script = ExtResource("2_lpckh")
|
||||
target_var = &"target"
|
||||
speed_var = &"speed"
|
||||
approach_distance = 100.0
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_lkphr"]
|
||||
time_limit = 1.0
|
||||
children = [SubResource("BTAction_jryg6")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_kidxn"]
|
||||
script = ExtResource("4_57x51")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_tadkc"]
|
||||
duration = 0.2
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_kcqly"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_hngi6"]
|
||||
await_completion = 2.0
|
||||
animation_player = SubResource("BBNode_kcqly")
|
||||
animation_name = &"attack_3"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_cm8jy"]
|
||||
duration = 0.5
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_ww5v2"]
|
||||
custom_name = "Melee attack"
|
||||
children = [SubResource("BTCondition_uk4dg"), SubResource("BTPlayAnimation_sty80"), SubResource("BTTimeLimit_lkphr"), SubResource("BTAction_kidxn"), SubResource("BTWait_tadkc"), SubResource("BTPlayAnimation_hngi6"), SubResource("BTWait_cm8jy")]
|
||||
|
||||
[sub_resource type="BTCooldown" id="BTCooldown_ksvfy"]
|
||||
duration = 2.0
|
||||
children = [SubResource("BTSequence_ww5v2")]
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_fpufi"]
|
||||
script = ExtResource("5_p5dih")
|
||||
distance_min = 0.0
|
||||
distance_max = 300.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_3iqcf"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_ee0ff"]
|
||||
animation_player = SubResource("BBNode_3iqcf")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
speed = -0.7
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_4ye2y"]
|
||||
script = ExtResource("6_fkv0k")
|
||||
speed_var = &"slow_speed"
|
||||
max_angle_deviation = 0.7
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_cns1i"]
|
||||
time_limit = 1.5
|
||||
children = [SubResource("BTAction_4ye2y")]
|
||||
|
||||
[sub_resource type="BTAlwaysSucceed" id="BTAlwaysSucceed_nw4ep"]
|
||||
children = [SubResource("BTTimeLimit_cns1i")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_81x7t"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_e61er"]
|
||||
animation_player = SubResource("BBNode_81x7t")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_jw0cm"]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_y12eg"]
|
||||
custom_name = "Disengage"
|
||||
children = [SubResource("BTCondition_fpufi"), SubResource("BTPlayAnimation_ee0ff"), SubResource("BTAlwaysSucceed_nw4ep"), SubResource("BTPlayAnimation_e61er"), SubResource("BTRandomWait_jw0cm")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_wpj6d"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_olf37"]
|
||||
animation_player = SubResource("BBNode_wpj6d")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
speed = 1.2
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_g5ayy"]
|
||||
script = ExtResource("2_cjso2")
|
||||
target_var = &"target"
|
||||
flank_side = 2
|
||||
range_min = 90
|
||||
range_max = 90
|
||||
position_var = &"flank_pos"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_tv4lt"]
|
||||
script = ExtResource("3_treio")
|
||||
target_position_var = &"flank_pos"
|
||||
speed_var = &"fast_speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &"target"
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_xek5v"]
|
||||
children = [SubResource("BTAction_tv4lt")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_rgwic"]
|
||||
custom_name = "Flank from behind"
|
||||
children = [SubResource("BTPlayAnimation_olf37"), SubResource("BTAction_g5ayy"), SubResource("BTTimeLimit_xek5v")]
|
||||
|
||||
[sub_resource type="BTSelector" id="BTSelector_2jnau"]
|
||||
children = [SubResource("BTRunLimit_tq3e1"), SubResource("BTCooldown_ksvfy"), SubResource("BTSequence_y12eg"), SubResource("BTSequence_rgwic")]
|
||||
|
||||
[resource]
|
||||
description = "Like actions, conditions do not contain child tasks within them. Instead, they evaluate specific criteria and return either a [SUCCESS] or [FAILURE] based on the agent's or environment's state (for example, \"IsLowOnHealth\", \"IsTargetInSight\"). Conditions are commonly employed alongside sequences to interrupt their execution if a particular requirement is not met.
|
||||
|
||||
In our example, if the target is not within the specified range, the [con]InRange[/con] condition will return [FAILURE], causing the [comp]sequence[/comp] to be aborted.
|
||||
"
|
||||
blackboard_plan = SubResource("BlackboardPlan_46tbn")
|
||||
root_task = SubResource("BTSelector_2jnau")
|
||||
182
demo/ai/trees/05_agent_ranged.tres
Normal file
182
demo/ai/trees/05_agent_ranged.tres
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=41 format=3 uid="uid://cqluon1y1hnn5"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_4xk1i"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/is_aligned_with_target.gd" id="2_a8qex"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="3_q4r2p"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_flanking_pos.gd" id="4_53hao"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="5_aexyq"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
var/run_speed/name = &"run_speed"
|
||||
var/run_speed/type = 3
|
||||
var/run_speed/value = 600.0
|
||||
var/run_speed/hint = 1
|
||||
var/run_speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_nrd4b"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qiw21"]
|
||||
animation_player = SubResource("BBNode_nrd4b")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_xlud8"]
|
||||
min_duration = 0.7
|
||||
max_duration = 1.5
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_c4cxo"]
|
||||
script = ExtResource("1_4xk1i")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_yhjh1"]
|
||||
custom_name = "Take a break"
|
||||
children = [SubResource("BTPlayAnimation_qiw21"), SubResource("BTRandomWait_xlud8"), SubResource("BTAction_c4cxo")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_ok0r5"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_unftu"]
|
||||
animation_player = SubResource("BBNode_ok0r5")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
speed = 1.5
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_op6l6"]
|
||||
script = ExtResource("4_53hao")
|
||||
target_var = &"target"
|
||||
flank_side = 1
|
||||
range_min = 400
|
||||
range_max = 1000
|
||||
position_var = &"pos"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_ycjun"]
|
||||
script = ExtResource("3_q4r2p")
|
||||
target_position_var = &"pos"
|
||||
speed_var = &"run_speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &"target"
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_gadc6"]
|
||||
time_limit = 7.0
|
||||
children = [SubResource("BTAction_ycjun")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_poqpu"]
|
||||
script = ExtResource("5_aexyq")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_0gdqn"]
|
||||
custom_name = "Change flank"
|
||||
children = [SubResource("BTPlayAnimation_unftu"), SubResource("BTAction_op6l6"), SubResource("BTTimeLimit_gadc6"), SubResource("BTAction_poqpu")]
|
||||
|
||||
[sub_resource type="BTCooldown" id="BTCooldown_2lneu"]
|
||||
duration = 7.0
|
||||
children = [SubResource("BTSequence_0gdqn")]
|
||||
|
||||
[sub_resource type="BTProbability" id="BTProbability_6sydk"]
|
||||
run_chance = 0.3
|
||||
children = [SubResource("BTCooldown_2lneu")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_kuuw2"]
|
||||
script = ExtResource("4_53hao")
|
||||
target_var = &"target"
|
||||
flank_side = 0
|
||||
range_min = 400
|
||||
range_max = 1000
|
||||
position_var = &"shoot_pos"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_kc64r"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_panch"]
|
||||
animation_player = SubResource("BBNode_kc64r")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_66hsk"]
|
||||
script = ExtResource("3_q4r2p")
|
||||
target_position_var = &"shoot_pos"
|
||||
speed_var = &"speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &""
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_24ath"]
|
||||
children = [SubResource("BTAction_66hsk")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_enw2m"]
|
||||
script = ExtResource("5_aexyq")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_1fnyc"]
|
||||
script = ExtResource("2_a8qex")
|
||||
target_var = &"target"
|
||||
tolerance = 150.0
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_s6vt4"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qa8jy"]
|
||||
animation_player = SubResource("BBNode_s6vt4")
|
||||
animation_name = &"throw_prepare"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_gbcyb"]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_qkfqt"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_0ktds"]
|
||||
await_completion = 1.0
|
||||
animation_player = SubResource("BBNode_qkfqt")
|
||||
animation_name = &"throw"
|
||||
blend = 0.05
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_1yxc5"]
|
||||
saved_value = NodePath(".")
|
||||
resource_name = "."
|
||||
|
||||
[sub_resource type="BTCallMethod" id="BTCallMethod_yx4fk"]
|
||||
node = SubResource("BBNode_1yxc5")
|
||||
method = &"throw_ninja_star"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_d2ib4"]
|
||||
duration = 0.2
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_rgbq3"]
|
||||
custom_name = "Throw ninja star"
|
||||
children = [SubResource("BTPlayAnimation_qa8jy"), SubResource("BTWait_gbcyb"), SubResource("BTPlayAnimation_0ktds"), SubResource("BTCallMethod_yx4fk"), SubResource("BTWait_d2ib4")]
|
||||
metadata/_weight_ = 1.0
|
||||
|
||||
[sub_resource type="BTRepeat" id="BTRepeat_g08ia"]
|
||||
times = 3
|
||||
children = [SubResource("BTSequence_rgbq3")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_lhg7f"]
|
||||
custom_name = "Get into position"
|
||||
children = [SubResource("BTAction_kuuw2"), SubResource("BTPlayAnimation_panch"), SubResource("BTTimeLimit_24ath"), SubResource("BTAction_enw2m"), SubResource("BTCondition_1fnyc"), SubResource("BTRepeat_g08ia")]
|
||||
metadata/_weight_ = 1.0
|
||||
|
||||
[sub_resource type="BTSelector" id="BTSelector_1rrya"]
|
||||
children = [SubResource("BTProbability_6sydk"), SubResource("BTSequence_lhg7f")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_pxl2k"]
|
||||
custom_name = "Main"
|
||||
children = [SubResource("BTSequence_yhjh1"), SubResource("BTSelector_1rrya")]
|
||||
|
||||
[resource]
|
||||
description = "Here, the [dec]Probability[/dec] decorator permits the execution of its branch in 30% of cases. This introduces a slight variation to the behavior each time the \"Change flank\" sequence is considered by the [comp]Selector[/comp].
|
||||
|
||||
The [dec]Repeat[/dec] decorator is handy for doing something multiple times within a behavior tree. In our example, it's used to make the [comp]Throw ninja star[/comp] sequence perform three times in a row."
|
||||
blackboard_plan = SubResource("BlackboardPlan_46tbn")
|
||||
root_task = SubResource("BTSequence_pxl2k")
|
||||
163
demo/ai/trees/06_agent_melee_combo.tres
Normal file
163
demo/ai/trees/06_agent_melee_combo.tres
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=39 format=3 uid="uid://cpncl1db8j12f"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_sf4l8"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_flanking_pos.gd" id="2_5nwkp"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="3_3tom2"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="4_hi228"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/move_forward.gd" id="5_au5yc"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
var/charge_speed/name = &"charge_speed"
|
||||
var/charge_speed/type = 3
|
||||
var/charge_speed/value = 1000.0
|
||||
var/charge_speed/hint = 0
|
||||
var/charge_speed/hint_string = ""
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_nrd4b"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qiw21"]
|
||||
animation_player = SubResource("BBNode_nrd4b")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_xlud8"]
|
||||
min_duration = 0.7
|
||||
max_duration = 1.5
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_ulbrf"]
|
||||
script = ExtResource("1_sf4l8")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_yhjh1"]
|
||||
custom_name = "Pause before action"
|
||||
children = [SubResource("BTPlayAnimation_qiw21"), SubResource("BTRandomWait_xlud8"), SubResource("BTAction_ulbrf")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_85keo"]
|
||||
script = ExtResource("2_5nwkp")
|
||||
target_var = &"target"
|
||||
flank_side = 0
|
||||
range_min = 300
|
||||
range_max = 400
|
||||
position_var = &"pos"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_wpj6d"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_olf37"]
|
||||
animation_player = SubResource("BBNode_wpj6d")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_ygjnc"]
|
||||
script = ExtResource("3_3tom2")
|
||||
target_position_var = &"pos"
|
||||
speed_var = &"speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &""
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_xek5v"]
|
||||
children = [SubResource("BTAction_ygjnc")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_1xfnq"]
|
||||
custom_name = "Align with player"
|
||||
children = [SubResource("BTAction_85keo"), SubResource("BTPlayAnimation_olf37"), SubResource("BTTimeLimit_xek5v")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_kidxn"]
|
||||
script = ExtResource("4_hi228")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_giv5l"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_usdja"]
|
||||
animation_player = SubResource("BBNode_giv5l")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_tadkc"]
|
||||
duration = 0.4
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_s8evu"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_ppmxd"]
|
||||
await_completion = 2.0
|
||||
animation_player = SubResource("BBNode_s8evu")
|
||||
animation_name = &"attack_1"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_u22bc"]
|
||||
script = ExtResource("5_au5yc")
|
||||
speed_var = &"charge_speed"
|
||||
duration = 0.1
|
||||
|
||||
[sub_resource type="BTParallel" id="BTParallel_ec2e3"]
|
||||
num_successes_required = 2
|
||||
children = [SubResource("BTPlayAnimation_ppmxd"), SubResource("BTAction_u22bc")]
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_c0lo0"]
|
||||
duration = 0.2
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_3oljv"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_q4uis"]
|
||||
await_completion = 2.0
|
||||
animation_player = SubResource("BBNode_3oljv")
|
||||
animation_name = &"attack_2"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_yuxl3"]
|
||||
script = ExtResource("5_au5yc")
|
||||
speed_var = &"charge_speed"
|
||||
duration = 0.1
|
||||
|
||||
[sub_resource type="BTParallel" id="BTParallel_thojy"]
|
||||
num_successes_required = 2
|
||||
children = [SubResource("BTPlayAnimation_q4uis"), SubResource("BTAction_yuxl3")]
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_y3pmv"]
|
||||
duration = 0.2
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_ot40l"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_ye5pt"]
|
||||
await_completion = 2.0
|
||||
animation_player = SubResource("BBNode_ot40l")
|
||||
animation_name = &"attack_3"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_rwp18"]
|
||||
script = ExtResource("5_au5yc")
|
||||
speed_var = &"charge_speed"
|
||||
duration = 0.1
|
||||
|
||||
[sub_resource type="BTParallel" id="BTParallel_qmdfb"]
|
||||
num_successes_required = 2
|
||||
children = [SubResource("BTPlayAnimation_ye5pt"), SubResource("BTAction_rwp18")]
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_nxyko"]
|
||||
duration = 0.5
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_ww5v2"]
|
||||
custom_name = "Combo Melee attack"
|
||||
children = [SubResource("BTAction_kidxn"), SubResource("BTPlayAnimation_usdja"), SubResource("BTWait_tadkc"), SubResource("BTParallel_ec2e3"), SubResource("BTWait_c0lo0"), SubResource("BTParallel_thojy"), SubResource("BTWait_y3pmv"), SubResource("BTParallel_qmdfb"), SubResource("BTWait_nxyko")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_pxl2k"]
|
||||
children = [SubResource("BTSequence_yhjh1"), SubResource("BTSequence_1xfnq"), SubResource("BTSequence_ww5v2")]
|
||||
|
||||
[resource]
|
||||
description = "In some scenarios, you might need to execute multiple tasks at the same time until specific conditions are fulfilled. To achieve this, the [comp]Parallel[/comp] composite is an invaluable tool. This composite task allows its children to be executed simultaneously during each tick until a specified number of successes or failures is reached. In this example, it will execute both the [act]PlayAnimation[/act] and [act]MoveForward[/act] actions each tick until both actions have finished with a [SUCCESS] status."
|
||||
blackboard_plan = SubResource("BlackboardPlan_46tbn")
|
||||
root_task = SubResource("BTSequence_pxl2k")
|
||||
219
demo/ai/trees/07_agent_melee_nuanced.tres
Normal file
219
demo/ai/trees/07_agent_melee_nuanced.tres
Normal file
|
|
@ -0,0 +1,219 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=49 format=3 uid="uid://c2u6sljqkim0n"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_08fik"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_flanking_pos.gd" id="2_te3yo"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="3_svwk8"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="4_mvsyw"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="5_r1ou0"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_46tbn"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
var/flank_speed/name = &"flank_speed"
|
||||
var/flank_speed/type = 3
|
||||
var/flank_speed/value = 600.0
|
||||
var/flank_speed/hint = 1
|
||||
var/flank_speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_nrd4b"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qiw21"]
|
||||
animation_player = SubResource("BBNode_nrd4b")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_xlud8"]
|
||||
min_duration = 0.7
|
||||
max_duration = 1.5
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_c4cxo"]
|
||||
script = ExtResource("1_08fik")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_yhjh1"]
|
||||
custom_name = "Pause before action"
|
||||
children = [SubResource("BTPlayAnimation_qiw21"), SubResource("BTRandomWait_xlud8"), SubResource("BTAction_c4cxo")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_kc64r"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_panch"]
|
||||
animation_player = SubResource("BBNode_kc64r")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
speed = 1.5
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_6e48s"]
|
||||
script = ExtResource("2_te3yo")
|
||||
target_var = &"target"
|
||||
flank_side = 1
|
||||
range_min = 400
|
||||
range_max = 600
|
||||
position_var = &"flank_pos"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_66hsk"]
|
||||
script = ExtResource("3_svwk8")
|
||||
target_position_var = &"flank_pos"
|
||||
speed_var = &"flank_speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &"target"
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_24ath"]
|
||||
children = [SubResource("BTAction_66hsk")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_enw2m"]
|
||||
script = ExtResource("4_mvsyw")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_lhg7f"]
|
||||
custom_name = "Flank player"
|
||||
children = [SubResource("BTPlayAnimation_panch"), SubResource("BTAction_6e48s"), SubResource("BTTimeLimit_24ath"), SubResource("BTAction_enw2m")]
|
||||
metadata/_weight_ = 1.0
|
||||
|
||||
[sub_resource type="BTCooldown" id="BTCooldown_skw41"]
|
||||
duration = 6.0
|
||||
children = [SubResource("BTSequence_lhg7f")]
|
||||
metadata/_weight_ = 2.0
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_wpj6d"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_olf37"]
|
||||
animation_player = SubResource("BBNode_wpj6d")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_a4jqi"]
|
||||
script = ExtResource("5_r1ou0")
|
||||
target_var = &"target"
|
||||
speed_var = &"speed"
|
||||
approach_distance = 100.0
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_xek5v"]
|
||||
time_limit = 2.0
|
||||
children = [SubResource("BTAction_a4jqi")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_kidxn"]
|
||||
script = ExtResource("4_mvsyw")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_tadkc"]
|
||||
duration = 0.1
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_g8qww"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_a8yqu"]
|
||||
await_completion = 2.0
|
||||
animation_player = SubResource("BBNode_g8qww")
|
||||
animation_name = &"attack_2"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_vjstl"]
|
||||
duration = 0.1
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_rfop0"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_8oyw6"]
|
||||
await_completion = 2.0
|
||||
animation_player = SubResource("BBNode_rfop0")
|
||||
animation_name = &"attack_3"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_1xfnq"]
|
||||
custom_name = "Approach and melee attack"
|
||||
children = [SubResource("BTPlayAnimation_olf37"), SubResource("BTTimeLimit_xek5v"), SubResource("BTAction_kidxn"), SubResource("BTWait_tadkc"), SubResource("BTPlayAnimation_a8yqu"), SubResource("BTWait_vjstl"), SubResource("BTPlayAnimation_8oyw6")]
|
||||
metadata/_weight_ = 4.0
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_mf87t"]
|
||||
script = ExtResource("2_te3yo")
|
||||
target_var = &"target"
|
||||
flank_side = 0
|
||||
range_min = 350
|
||||
range_max = 600
|
||||
position_var = &"pos"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_cx111"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_mfbeu"]
|
||||
animation_player = SubResource("BBNode_cx111")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_6nx58"]
|
||||
script = ExtResource("3_svwk8")
|
||||
target_position_var = &"pos"
|
||||
speed_var = &"speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &""
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_tidwl"]
|
||||
time_limit = 3.0
|
||||
children = [SubResource("BTAction_6nx58")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_8q20y"]
|
||||
script = ExtResource("4_mvsyw")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_s6vt4"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qa8jy"]
|
||||
animation_player = SubResource("BBNode_s6vt4")
|
||||
animation_name = &"throw_prepare"
|
||||
blend = 0.1
|
||||
speed = 0.7
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_gbcyb"]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_qkfqt"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_0ktds"]
|
||||
await_completion = 1.0
|
||||
animation_player = SubResource("BBNode_qkfqt")
|
||||
animation_name = &"throw"
|
||||
blend = 0.05
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_1yxc5"]
|
||||
saved_value = NodePath(".")
|
||||
resource_name = "."
|
||||
|
||||
[sub_resource type="BTCallMethod" id="BTCallMethod_yx4fk"]
|
||||
node = SubResource("BBNode_1yxc5")
|
||||
method = &"throw_ninja_star"
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_2pmoe"]
|
||||
max_duration = 1.5
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_rgbq3"]
|
||||
custom_name = "Throw ninja star"
|
||||
children = [SubResource("BTAction_mf87t"), SubResource("BTPlayAnimation_mfbeu"), SubResource("BTTimeLimit_tidwl"), SubResource("BTAction_8q20y"), SubResource("BTPlayAnimation_qa8jy"), SubResource("BTWait_gbcyb"), SubResource("BTPlayAnimation_0ktds"), SubResource("BTCallMethod_yx4fk"), SubResource("BTRandomWait_2pmoe")]
|
||||
metadata/_weight_ = 2.0
|
||||
|
||||
[sub_resource type="BTProbabilitySelector" id="BTProbabilitySelector_rjsiq"]
|
||||
abort_on_failure = true
|
||||
children = [SubResource("BTCooldown_skw41"), SubResource("BTSequence_1xfnq"), SubResource("BTSequence_rgbq3")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_pxl2k"]
|
||||
custom_name = "Main"
|
||||
children = [SubResource("BTSequence_yhjh1"), SubResource("BTProbabilitySelector_rjsiq")]
|
||||
|
||||
[resource]
|
||||
description = "[comp]ProbabilitySelector[/comp] chooses a child task to execute based on attached probabilities. Probability distribution is calculated based on weights assigned to each child task.
|
||||
"
|
||||
blackboard_plan = SubResource("BlackboardPlan_46tbn")
|
||||
root_task = SubResource("BTSequence_pxl2k")
|
||||
200
demo/ai/trees/08_agent_demon.tres
Normal file
200
demo/ai/trees/08_agent_demon.tres
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=49 format=3 uid="uid://cpcnbi81jqge4"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_ce4la"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/in_range.gd" id="2_atyuj"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="3_3mw7l"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/back_away.gd" id="4_6dr32"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_flanking_pos.gd" id="5_dho0d"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="6_0pfsl"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_8ay3j"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_lpri5"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_p3e7a"]
|
||||
animation_player = SubResource("BBNode_lpri5")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_j6cjm"]
|
||||
min_duration = 2.0
|
||||
max_duration = 3.0
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_5thv4"]
|
||||
custom_name = "Chill"
|
||||
children = [SubResource("BTPlayAnimation_p3e7a"), SubResource("BTRandomWait_j6cjm")]
|
||||
|
||||
[sub_resource type="BTCooldown" id="BTCooldown_oms7a"]
|
||||
trigger_on_failure = true
|
||||
children = [SubResource("BTSequence_5thv4")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_ohfp7"]
|
||||
script = ExtResource("1_ce4la")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_7a5nv"]
|
||||
script = ExtResource("2_atyuj")
|
||||
distance_min = 0.0
|
||||
distance_max = 150.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_ddvrs"]
|
||||
script = ExtResource("3_3mw7l")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_c4nfu"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_yytkn"]
|
||||
await_completion = 3.0
|
||||
animation_player = SubResource("BBNode_c4nfu")
|
||||
animation_name = &"attack_3"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTCooldown" id="BTCooldown_ejg6q"]
|
||||
duration = 3.0
|
||||
children = [SubResource("BTPlayAnimation_yytkn")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_eikr4"]
|
||||
custom_name = "Melee"
|
||||
children = [SubResource("BTAction_ohfp7"), SubResource("BTCondition_7a5nv"), SubResource("BTAction_ddvrs"), SubResource("BTCooldown_ejg6q")]
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_h75v8"]
|
||||
script = ExtResource("2_atyuj")
|
||||
distance_min = 0.0
|
||||
distance_max = 300.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_wpt7j"]
|
||||
script = ExtResource("3_3mw7l")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_iv62h"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_wnaul"]
|
||||
animation_player = SubResource("BBNode_iv62h")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
speed = -1.0
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_h2efl"]
|
||||
script = ExtResource("4_6dr32")
|
||||
speed_var = &"speed"
|
||||
max_angle_deviation = 0.7
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_wm5g2"]
|
||||
time_limit = 1.0
|
||||
children = [SubResource("BTAction_h2efl")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_wh4dl"]
|
||||
custom_name = "Back away"
|
||||
children = [SubResource("BTCondition_h75v8"), SubResource("BTAction_wpt7j"), SubResource("BTPlayAnimation_wnaul"), SubResource("BTTimeLimit_wm5g2")]
|
||||
|
||||
[sub_resource type="BTComment" id="BTComment_mqte5"]
|
||||
custom_name = "Get into position"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_edmui"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_vjtpq"]
|
||||
animation_player = SubResource("BBNode_edmui")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_4mmh0"]
|
||||
script = ExtResource("5_dho0d")
|
||||
target_var = &"target"
|
||||
flank_side = 0
|
||||
range_min = 300
|
||||
range_max = 700
|
||||
position_var = &"pos"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_vb5c3"]
|
||||
script = ExtResource("6_0pfsl")
|
||||
target_position_var = &"pos"
|
||||
speed_var = &"speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &""
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_jyks2"]
|
||||
children = [SubResource("BTAction_vb5c3")]
|
||||
|
||||
[sub_resource type="BTComment" id="BTComment_ym6nj"]
|
||||
custom_name = "Short break before action"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_fkevy"]
|
||||
script = ExtResource("3_3mw7l")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_lh25u"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_vcjeq"]
|
||||
animation_player = SubResource("BBNode_lh25u")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_42smh"]
|
||||
duration = 0.2
|
||||
|
||||
[sub_resource type="BTComment" id="BTComment_nbp2b"]
|
||||
custom_name = "Spit fire!"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_cqw71"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_214yn"]
|
||||
await_completion = 3.0
|
||||
animation_player = SubResource("BBNode_cqw71")
|
||||
animation_name = &"spit"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_dv5b5"]
|
||||
saved_value = NodePath(".")
|
||||
resource_name = "."
|
||||
|
||||
[sub_resource type="BTCallMethod" id="BTCallMethod_lk7i6"]
|
||||
node = SubResource("BBNode_dv5b5")
|
||||
method = &"spit_fire"
|
||||
|
||||
[sub_resource type="BTComment" id="BTComment_fndxk"]
|
||||
custom_name = "Wind down"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_m68ui"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_m7gyp"]
|
||||
animation_player = SubResource("BBNode_m68ui")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_v0el8"]
|
||||
min_duration = 0.7
|
||||
max_duration = 1.5
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_djtph"]
|
||||
custom_name = "Spit fire"
|
||||
children = [SubResource("BTComment_mqte5"), SubResource("BTPlayAnimation_vjtpq"), SubResource("BTAction_4mmh0"), SubResource("BTTimeLimit_jyks2"), SubResource("BTComment_ym6nj"), SubResource("BTAction_fkevy"), SubResource("BTPlayAnimation_vcjeq"), SubResource("BTWait_42smh"), SubResource("BTComment_nbp2b"), SubResource("BTPlayAnimation_214yn"), SubResource("BTCallMethod_lk7i6"), SubResource("BTComment_fndxk"), SubResource("BTPlayAnimation_m7gyp"), SubResource("BTRandomWait_v0el8")]
|
||||
|
||||
[sub_resource type="BTSelector" id="BTSelector_feba6"]
|
||||
children = [SubResource("BTCooldown_oms7a"), SubResource("BTSequence_eikr4"), SubResource("BTSequence_wh4dl"), SubResource("BTSequence_djtph")]
|
||||
|
||||
[resource]
|
||||
description = "Here, we use the [con]InRange[/con] condition task together with [comp]Sequence[/comp] and [comp]Selector[/comp] to create a reactive behavior for this agent. When the player comes close, this agent will attempt to hit them with a melee attack and move away afterward for a better ranged position."
|
||||
blackboard_plan = SubResource("BlackboardPlan_8ay3j")
|
||||
root_task = SubResource("BTSelector_feba6")
|
||||
155
demo/ai/trees/09_agent_summoner.tres
Normal file
155
demo/ai/trees/09_agent_summoner.tres
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=35 format=3 uid="uid://cpxk7jnqpwwlc"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_random_nearby_pos.gd" id="1_sgn0p"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="2_pshl2"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_58oq1"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 300.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
var/summon_cooldown/name = &"summon_cooldown"
|
||||
var/summon_cooldown/type = 1
|
||||
var/summon_cooldown/value = false
|
||||
var/summon_cooldown/hint = 0
|
||||
var/summon_cooldown/hint_string = ""
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_b7euf"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_sot6a"]
|
||||
animation_player = SubResource("BBNode_b7euf")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_0wc6p"]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_kwkxc"]
|
||||
custom_name = "Summoning sickness"
|
||||
children = [SubResource("BTPlayAnimation_sot6a"), SubResource("BTRandomWait_0wc6p")]
|
||||
|
||||
[sub_resource type="BTRunLimit" id="BTRunLimit_x2jr4"]
|
||||
children = [SubResource("BTSequence_kwkxc")]
|
||||
|
||||
[sub_resource type="BBVariant" id="BBVariant_y3x7n"]
|
||||
type = 2
|
||||
saved_value = 6
|
||||
resource_name = "6"
|
||||
|
||||
[sub_resource type="BTCheckAgentProperty" id="BTCheckAgentProperty_olmdj"]
|
||||
property = &"summon_count"
|
||||
check_type = 1
|
||||
value = SubResource("BBVariant_y3x7n")
|
||||
|
||||
[sub_resource type="BTComment" id="BTComment_ef6y0"]
|
||||
custom_name = "Variable $summon_cooldown is updated by the Cooldown task below"
|
||||
|
||||
[sub_resource type="BBVariant" id="BBVariant_hgde2"]
|
||||
type = 1
|
||||
saved_value = false
|
||||
resource_name = "false"
|
||||
|
||||
[sub_resource type="BTCheckVar" id="BTCheckVar_hc3o3"]
|
||||
variable = &"summon_cooldown"
|
||||
value = SubResource("BBVariant_hgde2")
|
||||
children = [SubResource("BTComment_ef6y0")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_q8bei"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_6leni"]
|
||||
animation_player = SubResource("BBNode_q8bei")
|
||||
animation_name = &"summon"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_8og18"]
|
||||
duration = 0.5
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_yeyns"]
|
||||
script = ExtResource("1_sgn0p")
|
||||
range_min = 300.0
|
||||
range_max = 500.0
|
||||
position_var = &"minion_pos"
|
||||
|
||||
[sub_resource type="BBVariant" id="BBVariant_wfjwy"]
|
||||
type = 5
|
||||
value_source = 1
|
||||
variable = &"minion_pos"
|
||||
resource_name = "$minion_pos"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_v271m"]
|
||||
saved_value = NodePath(".")
|
||||
resource_name = "."
|
||||
|
||||
[sub_resource type="BTCallMethod" id="BTCallMethod_4ath5"]
|
||||
node = SubResource("BBNode_v271m")
|
||||
method = &"summon_minion"
|
||||
args = Array[BBVariant]([SubResource("BBVariant_wfjwy")])
|
||||
|
||||
[sub_resource type="BTCooldown" id="BTCooldown_25f70"]
|
||||
duration = 6.0
|
||||
cooldown_state_var = &"summon_cooldown"
|
||||
children = [SubResource("BTCallMethod_4ath5")]
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_tdhfn"]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_2n742"]
|
||||
custom_name = "Summon minion"
|
||||
children = [SubResource("BTCheckAgentProperty_olmdj"), SubResource("BTCheckVar_hc3o3"), SubResource("BTPlayAnimation_6leni"), SubResource("BTWait_8og18"), SubResource("BTAction_yeyns"), SubResource("BTCooldown_25f70"), SubResource("BTWait_tdhfn")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_33wje"]
|
||||
script = ExtResource("1_sgn0p")
|
||||
range_min = 300.0
|
||||
range_max = 700.0
|
||||
position_var = &"pos"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_w5fh2"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qbxm8"]
|
||||
animation_player = SubResource("BBNode_w5fh2")
|
||||
animation_name = &"walk"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_dfifw"]
|
||||
script = ExtResource("2_pshl2")
|
||||
target_position_var = &"pos"
|
||||
speed_var = &"speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &""
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_i05cm"]
|
||||
time_limit = 3.0
|
||||
children = [SubResource("BTAction_dfifw")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_vinxt"]
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
resource_name = "AnimationPlayer"
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_t7drr"]
|
||||
animation_player = SubResource("BBNode_vinxt")
|
||||
animation_name = &"idle"
|
||||
blend = 0.1
|
||||
|
||||
[sub_resource type="BTRandomWait" id="BTRandomWait_axjfh"]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_ks71q"]
|
||||
custom_name = "Chill"
|
||||
children = [SubResource("BTPlayAnimation_t7drr"), SubResource("BTRandomWait_axjfh")]
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_dss4d"]
|
||||
custom_name = "Reposition"
|
||||
children = [SubResource("BTAction_33wje"), SubResource("BTPlayAnimation_qbxm8"), SubResource("BTTimeLimit_i05cm"), SubResource("BTSequence_ks71q")]
|
||||
|
||||
[sub_resource type="BTSelector" id="BTSelector_gp6q5"]
|
||||
children = [SubResource("BTRunLimit_x2jr4"), SubResource("BTSequence_2n742"), SubResource("BTSequence_dss4d")]
|
||||
|
||||
[resource]
|
||||
description = "[con]CheckAgentProperty[/con] examines the agent’s property value and compares it to a given value or a blackboard variable. In this example, it checks if the [color=cyan]summon_count[/color] property is less than 6.
|
||||
You can also check or share a [dec]Cooldown[/dec] in different parts of the behavior tree if you provide a blackboard variable for the [dec]Cooldown[/dec] decorator to use. [con]CheckVar[/con] is responsible here for examining the cooldown variable named \"summon_cooldown\"."
|
||||
blackboard_plan = SubResource("BlackboardPlan_58oq1")
|
||||
root_task = SubResource("BTSelector_gp6q5")
|
||||
29
demo/ai/trees/tutorial/tutorial_01_welcome.tres
Normal file
29
demo/ai/trees/tutorial/tutorial_01_welcome.tres
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=5 format=3 uid="uid://b1mfh8yad7rmw"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_fq0jf"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_rsejo"]
|
||||
animation_player = SubResource("BBNode_fq0jf")
|
||||
animation_name = &"idle"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_4bq32"]
|
||||
children = [SubResource("BTPlayAnimation_rsejo")]
|
||||
|
||||
[resource]
|
||||
description = "Welcome to the [b]LimboAI Tutorial[/b]!
|
||||
|
||||
Here, you'll learn how to use behavior trees to craft AI for your games. We'll start with the basics and gradually move to more advanced topics. Strap in for a quick and engaging introduction to behavior trees.
|
||||
|
||||
Press ➡ button in the top-right corner to proceed.
|
||||
Press ⬅ button any time you want to go back to a previous chapter."
|
||||
blackboard_plan = SubResource("BlackboardPlan_ewfwq")
|
||||
root_task = SubResource("BTSequence_4bq32")
|
||||
45
demo/ai/trees/tutorial/tutorial_02_introduction.tres
Normal file
45
demo/ai/trees/tutorial/tutorial_02_introduction.tres
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=9 format=3 uid="uid://b1i0xo0o676va"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
var/flank_speed/name = &"flank_speed"
|
||||
var/flank_speed/type = 3
|
||||
var/flank_speed/value = 600.0
|
||||
var/flank_speed/hint = 1
|
||||
var/flank_speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_wu06u"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_dubaq"]
|
||||
animation_player = SubResource("BBNode_wu06u")
|
||||
animation_name = &"idle"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_meli1"]
|
||||
duration = 5.0
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_mgehh"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_0fqno"]
|
||||
animation_player = SubResource("BBNode_mgehh")
|
||||
animation_name = &"dance"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_m3h4o"]
|
||||
duration = 5.0
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_rbfdh"]
|
||||
children = [SubResource("BTPlayAnimation_dubaq"), SubResource("BTWait_meli1"), SubResource("BTPlayAnimation_0fqno"), SubResource("BTWait_m3h4o")]
|
||||
|
||||
[resource]
|
||||
description = "Behavior trees are designed to simplify the creation of responsive and modular behaviors for games. They consist of tasks that represent specific actions or decision-making rules. Tasks can be broadly categorized into two groups: control tasks and leaf tasks. [b]Control tasks[/b] dictate the execution flow within the tree, while [b]leaf tasks[/b] represent specific actions to perform (such as moving or attacking) or conditions that need to be checked. Typically, it's the leaf tasks that perform the actual work in behavior trees.
|
||||
|
||||
A behavior tree is usually processed each frame (physics frame by default). It is traversed from top to bottom, with the control tasks determining the control flow. Each task has a [color=cyan]_tick[/color] method, which performs the task's work and returns a status indicating its progress: [SUCCESS], [FAILURE], or [RUNNING]. [SUCCESS] and [FAILURE] indicate the outcome of finished work, while [RUNNING] status is returned when a task requires more than one tick to complete its job. These statuses determine how the tree progresses, with the [RUNNING] status usually meaning that the tree will continue execution during the next frame."
|
||||
blackboard_plan = SubResource("BlackboardPlan_ewfwq")
|
||||
root_task = SubResource("BTSequence_rbfdh")
|
||||
97
demo/ai/trees/tutorial/tutorial_03_types.tres
Normal file
97
demo/ai/trees/tutorial/tutorial_03_types.tres
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=24 format=3 uid="uid://cb0ybf24ahnc3"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_random_nearby_pos.gd" id="1_as4cg"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="2_dlpnp"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="3_uv18s"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/in_range.gd" id="4_k3g8t"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="5_thvy5"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_20ku0"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_57u80"]
|
||||
animation_player = SubResource("BBNode_20ku0")
|
||||
animation_name = &"walk"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_11xvc"]
|
||||
script = ExtResource("1_as4cg")
|
||||
range_min = 300.0
|
||||
range_max = 500.0
|
||||
position_var = &"pos"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_tdkpj"]
|
||||
script = ExtResource("2_dlpnp")
|
||||
target_position_var = &"pos"
|
||||
speed_var = &"speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &""
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_echit"]
|
||||
children = [SubResource("BTPlayAnimation_57u80"), SubResource("BTAction_11xvc"), SubResource("BTAction_tdkpj")]
|
||||
|
||||
[sub_resource type="BTProbability" id="BTProbability_g0ol3"]
|
||||
children = [SubResource("BTSequence_echit")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_124bm"]
|
||||
script = ExtResource("3_uv18s")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_n25o8"]
|
||||
script = ExtResource("4_k3g8t")
|
||||
distance_min = 0.0
|
||||
distance_max = 200.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_1hfgr"]
|
||||
script = ExtResource("5_thvy5")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_ilr2h"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_mrsu3"]
|
||||
animation_player = SubResource("BBNode_ilr2h")
|
||||
animation_name = &"attack_1"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_5vug3"]
|
||||
children = [SubResource("BTAction_124bm"), SubResource("BTCondition_n25o8"), SubResource("BTAction_1hfgr"), SubResource("BTPlayAnimation_mrsu3")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_fq0jf"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_rsejo"]
|
||||
animation_player = SubResource("BBNode_fq0jf")
|
||||
animation_name = &"idle"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_dl31p"]
|
||||
duration = 2.0
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_vx4uy"]
|
||||
children = [SubResource("BTPlayAnimation_rsejo"), SubResource("BTWait_dl31p")]
|
||||
|
||||
[sub_resource type="BTSelector" id="BTSelector_tdpek"]
|
||||
children = [SubResource("BTProbability_g0ol3"), SubResource("BTSequence_5vug3"), SubResource("BTSequence_vx4uy")]
|
||||
|
||||
[resource]
|
||||
description = "There are four types of tasks:
|
||||
[ul][act]Actions[/act] are leaf tasks that perform the actual work.[/ul]
|
||||
[ul][con]Conditions[/con] are leaf tasks that conduct various checks.[/ul]
|
||||
[ul][comp]Composites[/comp] can have one or more child tasks, and dictate the execution flow of their children.[/ul]
|
||||
[ul][dec]Decorators[/dec] can only have a single child and they change how their child task operates.[/ul]
|
||||
|
||||
Let's take a look into actions first. [act]Actions[/act] are responsible for most of the work and often change the game state in a significant manner. For instance, [act]PlayAnimation[/act] instructs the AnimationPlayer to start a specified animation, with the option to wait for its completion. On the other hand, the [act]Wait[/act] task simply pauses for a set duration before returning [SUCCESS].
|
||||
|
||||
Next, we'll explore the core composite tasks, such as [comp]Sequence[/comp] and [comp]Selector[/comp]. These are among the most crucial composites that you should know about."
|
||||
blackboard_plan = SubResource("BlackboardPlan_ewfwq")
|
||||
root_task = SubResource("BTSelector_tdpek")
|
||||
62
demo/ai/trees/tutorial/tutorial_04_sequence.tres
Normal file
62
demo/ai/trees/tutorial/tutorial_04_sequence.tres
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=15 format=3 uid="uid://dln8ywvtqedt7"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_random_nearby_pos.gd" id="1_gk66j"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="2_v5eou"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_fq0jf"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_rsejo"]
|
||||
animation_player = SubResource("BBNode_fq0jf")
|
||||
animation_name = &"idle"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_dl31p"]
|
||||
duration = 3.0
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_6d0yy"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_wsspf"]
|
||||
animation_player = SubResource("BBNode_6d0yy")
|
||||
animation_name = &"walk"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_fc1oo"]
|
||||
script = ExtResource("1_gk66j")
|
||||
range_min = 300.0
|
||||
range_max = 500.0
|
||||
position_var = &"pos"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_djl5v"]
|
||||
script = ExtResource("2_v5eou")
|
||||
target_position_var = &"pos"
|
||||
speed_var = &"speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &""
|
||||
|
||||
[sub_resource type="BTFail" id="BTFail_i2f36"]
|
||||
|
||||
[sub_resource type="BTComment" id="BTComment_4i06i"]
|
||||
custom_name = "👇️ Sequence is never going to reach this task, because it fails at the previous step."
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_yxpnx"]
|
||||
duration = 888.0
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_vx4uy"]
|
||||
children = [SubResource("BTPlayAnimation_rsejo"), SubResource("BTWait_dl31p"), SubResource("BTPlayAnimation_wsspf"), SubResource("BTAction_fc1oo"), SubResource("BTAction_djl5v"), SubResource("BTFail_i2f36"), SubResource("BTComment_4i06i"), SubResource("BTWait_yxpnx")]
|
||||
|
||||
[resource]
|
||||
description = "The [comp]Sequence[/comp] is one of the core composite tasks. It executes its child tasks sequentially, from first to last, until one of them returns [FAILURE], or all of them result in [SUCCESS]. In other words, if any child task results in [FAILURE], the Sequence execution will be aborted, and the Sequence itself will return [FAILURE].
|
||||
|
||||
In our example, you can observe a simple [comp]Sequence[/comp] in action. Notice how it fails when it reaches the [act]Fail[/act] action and never proceeds to the [act]Wait 888 sec[/act] action afterward. By the way, the simple [act]Fail[/act] task is quite useful for troubleshooting. Its sole function is to return [FAILURE].
|
||||
"
|
||||
blackboard_plan = SubResource("BlackboardPlan_ewfwq")
|
||||
root_task = SubResource("BTSequence_vx4uy")
|
||||
108
demo/ai/trees/tutorial/tutorial_05_selector.tres
Normal file
108
demo/ai/trees/tutorial/tutorial_05_selector.tres
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=26 format=3 uid="uid://bf4r652fv5kwi"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_3ed74"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_random_nearby_pos.gd" id="1_rvh1c"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/in_range.gd" id="2_jfsyt"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="2_nnswb"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="2_t62a0"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_x0uu7"]
|
||||
script = ExtResource("2_jfsyt")
|
||||
distance_min = 0.0
|
||||
distance_max = 200.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_icf24"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_iiei3"]
|
||||
animation_player = SubResource("BBNode_icf24")
|
||||
animation_name = &"walk"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_824oc"]
|
||||
script = ExtResource("1_rvh1c")
|
||||
range_min = 700.0
|
||||
range_max = 800.0
|
||||
position_var = &"pos"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_y1you"]
|
||||
script = ExtResource("2_t62a0")
|
||||
target_position_var = &"pos"
|
||||
speed_var = &"speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &""
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_ayt56"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_l1tdg"]
|
||||
animation_player = SubResource("BBNode_ayt56")
|
||||
animation_name = &"idle"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_hh8ys"]
|
||||
duration = 3.0
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_cgwor"]
|
||||
children = [SubResource("BTCondition_x0uu7"), SubResource("BTPlayAnimation_iiei3"), SubResource("BTAction_824oc"), SubResource("BTAction_y1you"), SubResource("BTPlayAnimation_l1tdg"), SubResource("BTWait_hh8ys")]
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_d6aub"]
|
||||
script = ExtResource("2_jfsyt")
|
||||
distance_min = 200.0
|
||||
distance_max = 10000.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_6d0yy"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_wsspf"]
|
||||
animation_player = SubResource("BBNode_6d0yy")
|
||||
animation_name = &"walk"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_wc11r"]
|
||||
script = ExtResource("2_nnswb")
|
||||
target_var = &"target"
|
||||
speed_var = &"speed"
|
||||
approach_distance = 100.0
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_aw5jj"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_3aihc"]
|
||||
animation_player = SubResource("BBNode_aw5jj")
|
||||
animation_name = &"idle"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_1o163"]
|
||||
duration = 3.0
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_vx4uy"]
|
||||
children = [SubResource("BTCondition_d6aub"), SubResource("BTPlayAnimation_wsspf"), SubResource("BTAction_wc11r"), SubResource("BTPlayAnimation_3aihc"), SubResource("BTWait_1o163")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_2murg"]
|
||||
script = ExtResource("1_3ed74")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BTSelector" id="BTSelector_ddhoo"]
|
||||
children = [SubResource("BTSequence_cgwor"), SubResource("BTSequence_vx4uy"), SubResource("BTAction_2murg")]
|
||||
|
||||
[resource]
|
||||
description = "The [comp]Selector[/comp] is another essential composite task. It executes its child tasks sequentially, from first to last, until one of them returns [SUCCESS] or all of them result in [FAILURE]. In other words, when a child task results in [FAILURE], it moves on to the next one until it finds the one that returns [SUCCESS]. Once a child task results in [SUCCESS], the Selector stops and also returns [SUCCESS].
|
||||
|
||||
To understand the [comp]Selector[/comp], it helps to see it as the opposite of the [comp]Sequence[/comp]. While the Sequence continues iterating over children as long as they return [SUCCESS], the Selector does the same but as long as they return [FAILURE]. The purpose of the Selector is to find a child that succeeds. It's often useful to place higher priority tasks at the top so that the Selector attempts them first.
|
||||
|
||||
[comp]Selector[/comp] is frequently used with [comp]Sequence[/comp] and [con]Condition[/con] tasks to control the behavior tree's flow. A condition task would prevent a Sequence from proceeding if it evaluates to [FAILURE], and thus the Selector would try the next child.
|
||||
|
||||
In our example, the [con]InRange[/con] condition checks how far Junior is from the target. When Junior is farther than 200 pixels from the target, he'll attempt to approach it. If he is closer than 200 pixels from the target, he would try to walk away. Thanks to the Selector, only one of these behaviors will be performed at a time, based on the result of the [con]InRange[/con] check. Junior seems to have a dilemma — unable to decide whether to stay or go."
|
||||
blackboard_plan = SubResource("BlackboardPlan_ewfwq")
|
||||
root_task = SubResource("BTSelector_ddhoo")
|
||||
136
demo/ai/trees/tutorial/tutorial_06_decorators.tres
Normal file
136
demo/ai/trees/tutorial/tutorial_06_decorators.tres
Normal file
|
|
@ -0,0 +1,136 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=34 format=3 uid="uid://beiki511huxb8"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_3xoj7"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/in_range.gd" id="2_08b67"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="3_orhnl"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_random_nearby_pos.gd" id="4_oyght"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="5_5o1gy"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="6_rpn40"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_2murg"]
|
||||
script = ExtResource("1_3xoj7")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BTRunLimit" id="BTRunLimit_60b8b"]
|
||||
children = [SubResource("BTAction_2murg")]
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_m15aa"]
|
||||
script = ExtResource("2_08b67")
|
||||
distance_min = 0.0
|
||||
distance_max = 200.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_oc76s"]
|
||||
script = ExtResource("3_orhnl")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_6d0yy"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_wsspf"]
|
||||
await_completion = 5.0
|
||||
animation_player = SubResource("BBNode_6d0yy")
|
||||
animation_name = &"attack_1"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_e0f8v"]
|
||||
children = [SubResource("BTCondition_m15aa"), SubResource("BTAction_oc76s"), SubResource("BTPlayAnimation_wsspf")]
|
||||
|
||||
[sub_resource type="BTCooldown" id="BTCooldown_3tvjt"]
|
||||
children = [SubResource("BTSequence_e0f8v")]
|
||||
duration = 5.0
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_x0uu7"]
|
||||
script = ExtResource("2_08b67")
|
||||
distance_min = 0.0
|
||||
distance_max = 200.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_icf24"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_iiei3"]
|
||||
animation_player = SubResource("BBNode_icf24")
|
||||
animation_name = &"walk"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_824oc"]
|
||||
script = ExtResource("4_oyght")
|
||||
range_min = 700.0
|
||||
range_max = 800.0
|
||||
position_var = &"pos"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_y1you"]
|
||||
script = ExtResource("5_5o1gy")
|
||||
target_position_var = &"pos"
|
||||
speed_var = &"speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &""
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_ayt56"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_l1tdg"]
|
||||
animation_player = SubResource("BBNode_ayt56")
|
||||
animation_name = &"idle"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_hh8ys"]
|
||||
duration = 3.0
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_cgwor"]
|
||||
children = [SubResource("BTCondition_x0uu7"), SubResource("BTPlayAnimation_iiei3"), SubResource("BTAction_824oc"), SubResource("BTAction_y1you"), SubResource("BTPlayAnimation_l1tdg"), SubResource("BTWait_hh8ys")]
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_d6aub"]
|
||||
script = ExtResource("2_08b67")
|
||||
distance_min = 200.0
|
||||
distance_max = 10000.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_rpwld"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_dug2k"]
|
||||
animation_player = SubResource("BBNode_rpwld")
|
||||
animation_name = &"walk"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_wc11r"]
|
||||
script = ExtResource("6_rpn40")
|
||||
target_var = &"target"
|
||||
speed_var = &"speed"
|
||||
approach_distance = 100.0
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_aw5jj"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_3aihc"]
|
||||
animation_player = SubResource("BBNode_aw5jj")
|
||||
animation_name = &"idle"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_1o163"]
|
||||
duration = 0.5
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_vx4uy"]
|
||||
children = [SubResource("BTCondition_d6aub"), SubResource("BTPlayAnimation_dug2k"), SubResource("BTAction_wc11r"), SubResource("BTPlayAnimation_3aihc"), SubResource("BTWait_1o163")]
|
||||
|
||||
[sub_resource type="BTSelector" id="BTSelector_ddhoo"]
|
||||
children = [SubResource("BTRunLimit_60b8b"), SubResource("BTCooldown_3tvjt"), SubResource("BTSequence_cgwor"), SubResource("BTSequence_vx4uy")]
|
||||
|
||||
[resource]
|
||||
description = "Let's improve our previous behavior, and take the opportunity to discuss [dec]Decorators[/dec]. As mentioned earlier, decorators are control tasks that should only have a single child. Typically, a decorator either alters how its child operates or modifies its return status. They are often a useful tool for introducing variance into behaviors that otherwise lack it.
|
||||
|
||||
In our example, we utilize the [dec]RunLimit[/dec] decorator to restrict its child from running more than once. After executing the first time, the child will never receive another tick. This is quite handy for all sorts of setup logic!
|
||||
|
||||
Now, let's examine another decorator we use here - the [dec]Cooldown[/dec]. This decorator executes its child task only if the specified duration time has passed since the previous execution of the child task. The first time the attack sequence results in [SUCCESS], it triggers the cooldown, preventing the [comp]Sequence[/comp] from being executed for the next 5 seconds. During this period, the Cooldown returns [FAILURE] until the specified duration time elapses. It's important to note that it only counts executions that finished with [SUCCESS]. This means that [con]InRange[/con] can be utilized here without triggering the Cooldown!"
|
||||
blackboard_plan = SubResource("BlackboardPlan_ewfwq")
|
||||
root_task = SubResource("BTSelector_ddhoo")
|
||||
143
demo/ai/trees/tutorial/tutorial_07_more_decorators.tres
Normal file
143
demo/ai/trees/tutorial/tutorial_07_more_decorators.tres
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=36 format=3 uid="uid://tep50j4d6kgp"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_f605f"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/in_range.gd" id="2_mj1cj"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="3_86p0r"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/back_away.gd" id="4_u0vk1"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="6_1yikm"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_2murg"]
|
||||
script = ExtResource("1_f605f")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BTRunLimit" id="BTRunLimit_60b8b"]
|
||||
children = [SubResource("BTAction_2murg")]
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_m15aa"]
|
||||
script = ExtResource("2_mj1cj")
|
||||
distance_min = 0.0
|
||||
distance_max = 200.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_oc76s"]
|
||||
script = ExtResource("3_86p0r")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_6d0yy"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_wsspf"]
|
||||
await_completion = 5.0
|
||||
animation_player = SubResource("BBNode_6d0yy")
|
||||
animation_name = &"attack_1"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_w45kn"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_d2lad"]
|
||||
await_completion = 5.0
|
||||
animation_player = SubResource("BBNode_w45kn")
|
||||
animation_name = &"attack_2"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_e0f8v"]
|
||||
children = [SubResource("BTCondition_m15aa"), SubResource("BTAction_oc76s"), SubResource("BTPlayAnimation_wsspf"), SubResource("BTPlayAnimation_d2lad")]
|
||||
|
||||
[sub_resource type="BTCooldown" id="BTCooldown_3tvjt"]
|
||||
children = [SubResource("BTSequence_e0f8v")]
|
||||
duration = 5.0
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_x0uu7"]
|
||||
script = ExtResource("2_mj1cj")
|
||||
distance_min = 0.0
|
||||
distance_max = 200.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_wksgd"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_umlwj"]
|
||||
animation_player = SubResource("BBNode_wksgd")
|
||||
animation_name = &"walk"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_6q0k4"]
|
||||
script = ExtResource("4_u0vk1")
|
||||
speed_var = &"speed"
|
||||
max_angle_deviation = 0.7
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_6eii7"]
|
||||
children = [SubResource("BTAction_6q0k4")]
|
||||
time_limit = 2.0
|
||||
|
||||
[sub_resource type="BTAlwaysSucceed" id="BTAlwaysSucceed_ieord"]
|
||||
children = [SubResource("BTTimeLimit_6eii7")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_ayt56"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_l1tdg"]
|
||||
animation_player = SubResource("BBNode_ayt56")
|
||||
animation_name = &"idle"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_hh8ys"]
|
||||
duration = 3.0
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_cgwor"]
|
||||
children = [SubResource("BTCondition_x0uu7"), SubResource("BTPlayAnimation_umlwj"), SubResource("BTAlwaysSucceed_ieord"), SubResource("BTPlayAnimation_l1tdg"), SubResource("BTWait_hh8ys")]
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_d6aub"]
|
||||
script = ExtResource("2_mj1cj")
|
||||
distance_min = 200.0
|
||||
distance_max = 10000.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_rpwld"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_dug2k"]
|
||||
animation_player = SubResource("BBNode_rpwld")
|
||||
animation_name = &"walk"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_wc11r"]
|
||||
script = ExtResource("6_1yikm")
|
||||
target_var = &"target"
|
||||
speed_var = &"speed"
|
||||
approach_distance = 100.0
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_aw5jj"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_3aihc"]
|
||||
animation_player = SubResource("BBNode_aw5jj")
|
||||
animation_name = &"idle"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_1o163"]
|
||||
duration = 0.5
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_vx4uy"]
|
||||
children = [SubResource("BTCondition_d6aub"), SubResource("BTPlayAnimation_dug2k"), SubResource("BTAction_wc11r"), SubResource("BTPlayAnimation_3aihc"), SubResource("BTWait_1o163")]
|
||||
|
||||
[sub_resource type="BTSelector" id="BTSelector_ddhoo"]
|
||||
children = [SubResource("BTRunLimit_60b8b"), SubResource("BTCooldown_3tvjt"), SubResource("BTSequence_cgwor"), SubResource("BTSequence_vx4uy")]
|
||||
|
||||
[resource]
|
||||
description = "Let's explore some other [dec]Decorators[/dec]. Here's a slightly improved version of the previous behavior. We incorporate the [dec]TimeLimit[/dec] decorator with the [act]Back Away[/act] action to achieve a similar effect as before (walking away from the target). The TimeLimit decorator ensures that the child task does not take too long to finish its work. If the time runs out, the task's execution will be aborted, and TimeLimit will return [FAILURE].
|
||||
|
||||
Another useful decorator is [dec]AlwaysSucceed[/dec], which converts any [FAILURE] returned by its child into [SUCCESS]. We use this decorator here because TimeLimit may result in [FAILURE], but we still want the [comp]Sequence[/comp] to continue. Also, there are similar decorators such as [dec]AlwaysFail[/dec] and [dec]Invert[/dec], which you can use in your behavior trees as needed.
|
||||
|
||||
We also add a second attack, so that Junior feels more badass now. We've got a little hit-and-run behavior going on here!"
|
||||
blackboard_plan = SubResource("BlackboardPlan_ewfwq")
|
||||
root_task = SubResource("BTSelector_ddhoo")
|
||||
204
demo/ai/trees/tutorial/tutorial_08_final_touch.tres
Normal file
204
demo/ai/trees/tutorial/tutorial_08_final_touch.tres
Normal file
|
|
@ -0,0 +1,204 @@
|
|||
[gd_resource type="BehaviorTree" load_steps=52 format=3 uid="uid://dp0cglcytwcj5"]
|
||||
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/get_first_in_group.gd" id="1_o5ahw"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/select_flanking_pos.gd" id="2_er25a"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/arrive_pos.gd" id="3_ed1xo"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/face_target.gd" id="4_128ei"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/in_range.gd" id="5_er18b"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/back_away.gd" id="6_1urfq"]
|
||||
[ext_resource type="Script" path="res://demo/ai/tasks/pursue.gd" id="7_ekws5"]
|
||||
|
||||
[sub_resource type="BlackboardPlan" id="BlackboardPlan_ewfwq"]
|
||||
var/speed/name = &"speed"
|
||||
var/speed/type = 3
|
||||
var/speed/value = 400.0
|
||||
var/speed/hint = 1
|
||||
var/speed/hint_string = "10,1000,10"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_2murg"]
|
||||
script = ExtResource("1_o5ahw")
|
||||
group = &"player"
|
||||
output_var = &"target"
|
||||
|
||||
[sub_resource type="BTRunLimit" id="BTRunLimit_60b8b"]
|
||||
children = [SubResource("BTAction_2murg")]
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_m15aa"]
|
||||
script = ExtResource("5_er18b")
|
||||
distance_min = 0.0
|
||||
distance_max = 200.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_oc76s"]
|
||||
script = ExtResource("4_128ei")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_6d0yy"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_wsspf"]
|
||||
await_completion = 5.0
|
||||
animation_player = SubResource("BBNode_6d0yy")
|
||||
animation_name = &"attack_1"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_w45kn"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_d2lad"]
|
||||
await_completion = 5.0
|
||||
animation_player = SubResource("BBNode_w45kn")
|
||||
animation_name = &"attack_2"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_e0f8v"]
|
||||
children = [SubResource("BTCondition_m15aa"), SubResource("BTAction_oc76s"), SubResource("BTPlayAnimation_wsspf"), SubResource("BTPlayAnimation_d2lad")]
|
||||
|
||||
[sub_resource type="BTCooldown" id="BTCooldown_3tvjt"]
|
||||
children = [SubResource("BTSequence_e0f8v")]
|
||||
duration = 5.0
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_x0uu7"]
|
||||
script = ExtResource("5_er18b")
|
||||
distance_min = 0.0
|
||||
distance_max = 200.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_wksgd"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_umlwj"]
|
||||
animation_player = SubResource("BBNode_wksgd")
|
||||
animation_name = &"walk"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_6q0k4"]
|
||||
script = ExtResource("6_1urfq")
|
||||
speed_var = &"speed"
|
||||
max_angle_deviation = 0.7
|
||||
|
||||
[sub_resource type="BTTimeLimit" id="BTTimeLimit_6eii7"]
|
||||
children = [SubResource("BTAction_6q0k4")]
|
||||
time_limit = 2.0
|
||||
|
||||
[sub_resource type="BTAlwaysSucceed" id="BTAlwaysSucceed_ieord"]
|
||||
children = [SubResource("BTTimeLimit_6eii7")]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_ayt56"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_l1tdg"]
|
||||
animation_player = SubResource("BBNode_ayt56")
|
||||
animation_name = &"idle"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_hh8ys"]
|
||||
duration = 3.0
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_cgwor"]
|
||||
children = [SubResource("BTCondition_x0uu7"), SubResource("BTPlayAnimation_umlwj"), SubResource("BTAlwaysSucceed_ieord"), SubResource("BTPlayAnimation_l1tdg"), SubResource("BTWait_hh8ys")]
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_n0rxm"]
|
||||
script = ExtResource("2_er25a")
|
||||
target_var = &"target"
|
||||
flank_side = 0
|
||||
range_min = 400
|
||||
range_max = 500
|
||||
position_var = &"pos"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_icf24"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_iiei3"]
|
||||
animation_player = SubResource("BBNode_icf24")
|
||||
animation_name = &"walk"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_g2up4"]
|
||||
script = ExtResource("3_ed1xo")
|
||||
target_position_var = &"pos"
|
||||
speed_var = &"speed"
|
||||
tolerance = 50.0
|
||||
avoid_var = &""
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_d5lkr"]
|
||||
script = ExtResource("4_128ei")
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_h4k80"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_40yja"]
|
||||
animation_player = SubResource("BBNode_h4k80")
|
||||
animation_name = &"throw_prepare"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_2dc1v"]
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_slipn"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_qnpjq"]
|
||||
await_completion = 5.0
|
||||
animation_player = SubResource("BBNode_slipn")
|
||||
animation_name = &"throw"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_qaqnn"]
|
||||
resource_name = "."
|
||||
saved_value = NodePath(".")
|
||||
|
||||
[sub_resource type="BTCallMethod" id="BTCallMethod_yd0fn"]
|
||||
node = SubResource("BBNode_qaqnn")
|
||||
method = &"throw_ninja_star"
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_ws7nq"]
|
||||
children = [SubResource("BTAction_n0rxm"), SubResource("BTPlayAnimation_iiei3"), SubResource("BTAction_g2up4"), SubResource("BTAction_d5lkr"), SubResource("BTPlayAnimation_40yja"), SubResource("BTWait_2dc1v"), SubResource("BTPlayAnimation_qnpjq"), SubResource("BTCallMethod_yd0fn")]
|
||||
|
||||
[sub_resource type="BTProbability" id="BTProbability_omklt"]
|
||||
children = [SubResource("BTSequence_ws7nq")]
|
||||
run_chance = 0.25
|
||||
|
||||
[sub_resource type="BTCondition" id="BTCondition_d6aub"]
|
||||
script = ExtResource("5_er18b")
|
||||
distance_min = 200.0
|
||||
distance_max = 10000.0
|
||||
target_var = &"target"
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_rpwld"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_dug2k"]
|
||||
animation_player = SubResource("BBNode_rpwld")
|
||||
animation_name = &"walk"
|
||||
|
||||
[sub_resource type="BTAction" id="BTAction_wc11r"]
|
||||
script = ExtResource("7_ekws5")
|
||||
target_var = &"target"
|
||||
speed_var = &"speed"
|
||||
approach_distance = 100.0
|
||||
|
||||
[sub_resource type="BBNode" id="BBNode_aw5jj"]
|
||||
resource_name = "AnimationPlayer"
|
||||
saved_value = NodePath("AnimationPlayer")
|
||||
|
||||
[sub_resource type="BTPlayAnimation" id="BTPlayAnimation_3aihc"]
|
||||
animation_player = SubResource("BBNode_aw5jj")
|
||||
animation_name = &"idle"
|
||||
|
||||
[sub_resource type="BTWait" id="BTWait_1o163"]
|
||||
duration = 0.5
|
||||
|
||||
[sub_resource type="BTSequence" id="BTSequence_vx4uy"]
|
||||
children = [SubResource("BTCondition_d6aub"), SubResource("BTPlayAnimation_dug2k"), SubResource("BTAction_wc11r"), SubResource("BTPlayAnimation_3aihc"), SubResource("BTWait_1o163")]
|
||||
|
||||
[sub_resource type="BTSelector" id="BTSelector_ddhoo"]
|
||||
children = [SubResource("BTRunLimit_60b8b"), SubResource("BTCooldown_3tvjt"), SubResource("BTSequence_cgwor"), SubResource("BTProbability_omklt"), SubResource("BTSequence_vx4uy")]
|
||||
|
||||
[resource]
|
||||
description = "And for the final touch, we've added throwing ninja stars to our previous behavior. The [dec]Probability[/dec] decorator adds a little variance so that we don't throw ninja stars all the time. This decorator executes its child task with a certain probability, so when it's not 100%, sometimes it will return [FAILURE] instead. Some of the work in this [comp]Sequence[/comp] is done by actions you've seen already, and the [act]CallMethod[/act] action invokes the [color=cyan]throw_ninja_star[/color] method on the agent node. By the way, the agent is always the owner of the BTPlayer node, which executes this behavior tree.
|
||||
|
||||
This concludes our tutorial. Hopefully, this little endeavor has been useful to you. You can learn more by reading the [b]Online Documentation[/b], which covers topics like creating your own tasks. Also, check out the [b]Showcase[/b], which presents behaviors of agents made for this little demo. Simply click \"End Tutorial\" to return to the [b]Showcase[/b]."
|
||||
blackboard_plan = SubResource("BlackboardPlan_ewfwq")
|
||||
root_task = SubResource("BTSelector_ddhoo")
|
||||
Loading…
Add table
Add a link
Reference in a new issue