Play ball with the enemy

Enemy can return the ball to the player
This commit is contained in:
Mathilde Grapin 2023-06-27 21:25:32 +02:00
parent 332c0fb0e1
commit e0633efcbe
14 changed files with 139 additions and 44 deletions

View file

@ -162,4 +162,16 @@ libraries = {
position = Vector2(-0.5, -5)
shape = SubResource("RectangleShape2D_rlijp")
[node name="Area2D" type="Area2D" parent="."]
collision_layer = 2
collision_mask = 8
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
position = Vector2(-0.5, -5)
shape = SubResource("RectangleShape2D_rlijp")
[node name="EnemyBehaviorTree" parent="." instance=ExtResource("3_jk76t")]
[connection signal="go_to_ball" from="." to="EnemyBehaviorTree" method="_on_enemy_go_to_ball"]
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]
[connection signal="body_exited" from="Area2D" to="." method="_on_area_2d_body_exited"]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=13 format=3 uid="uid://b51tdt5kunai"]
[gd_scene load_steps=15 format=3 uid="uid://b51tdt5kunai"]
[ext_resource type="Script" path="res://addons/beehave/nodes/beehave_tree.gd" id="1_b2pc4"]
[ext_resource type="Script" path="res://addons/beehave/nodes/composites/sequence.gd" id="2_80fm4"]
@ -9,9 +9,11 @@
[ext_resource type="Script" path="res://scripts/enemy/behavior_tree/can_throw_ball_condition.gd" id="7_k5qlq"]
[ext_resource type="Script" path="res://scripts/enemy/behavior_tree/throw_ball_action.gd" id="8_wytqf"]
[ext_resource type="Script" path="res://scripts/enemy/behavior_tree/get_random_target_action.gd" id="8_y68xp"]
[ext_resource type="Script" path="res://scripts/enemy/behavior_tree/is_idle_condition.gd" id="9_vboat"]
[ext_resource type="Script" path="res://scripts/enemy/behavior_tree/get_random_destination_action.gd" id="10_f4jrw"]
[ext_resource type="Script" path="res://scripts/enemy/behavior_tree/can_go_to_ball_condition.gd" id="10_3puvl"]
[ext_resource type="Script" path="res://scripts/enemy/behavior_tree/get_ball_destination_action.gd" id="11_bvy6m"]
[ext_resource type="Script" path="res://scripts/enemy/behavior_tree/move_to_destination_action.gd" id="11_tjc85"]
[ext_resource type="Script" path="res://scripts/enemy/behavior_tree/can_return_ball_condition.gd" id="13_lrd2w"]
[ext_resource type="Script" path="res://scripts/enemy/behavior_tree/return_ball_action.gd" id="14_qbh47"]
[node name="EnemyBehaviorTree" type="Node"]
script = ExtResource("1_b2pc4")
@ -44,14 +46,26 @@ script = ExtResource("8_y68xp")
[node name="ThrowBall" type="Node" parent="MainSelector/ThrowBallSequence"]
script = ExtResource("8_wytqf")
[node name="ReturnBallSequence" type="Node" parent="MainSelector"]
[node name="GoToBallSequence" type="Node" parent="MainSelector"]
script = ExtResource("2_80fm4")
[node name="IsIdle" type="Node" parent="MainSelector/ReturnBallSequence"]
script = ExtResource("9_vboat")
[node name="CanGoToBall" type="Node" parent="MainSelector/GoToBallSequence"]
script = ExtResource("10_3puvl")
[node name="GetRandomDestination" type="Node" parent="MainSelector/ReturnBallSequence"]
script = ExtResource("10_f4jrw")
[node name="GetBallDestination" type="Node" parent="MainSelector/GoToBallSequence"]
script = ExtResource("11_bvy6m")
[node name="MoveToDestination" type="Node" parent="MainSelector/ReturnBallSequence"]
[node name="MoveToDestination" type="Node" parent="MainSelector/GoToBallSequence"]
script = ExtResource("11_tjc85")
[node name="SequenceComposite" type="Node" parent="MainSelector"]
script = ExtResource("2_80fm4")
[node name="CanReturnBall" type="Node" parent="MainSelector/SequenceComposite"]
script = ExtResource("13_lrd2w")
[node name="GetRandomTarget2" type="Node" parent="MainSelector/SequenceComposite"]
script = ExtResource("8_y68xp")
[node name="ReturnBall" type="Node" parent="MainSelector/SequenceComposite"]
script = ExtResource("14_qbh47")