Player throw back the ball from walk or idle state

This commit is contained in:
Mathilde Grapin 2023-06-18 20:30:25 +02:00
parent 1aff1c2e38
commit 332c0fb0e1
16 changed files with 165 additions and 25 deletions

View file

@ -1,12 +1,16 @@
[gd_scene load_steps=3 format=3 uid="uid://cy0ko2cawudia"]
[gd_scene load_steps=4 format=3 uid="uid://cy0ko2cawudia"]
[ext_resource type="Script" path="res://scripts/ball/ball.gd" id="1_8tu7d"]
[ext_resource type="Texture2D" uid="uid://dl8qfp3u18nkx" path="res://art/objects/ball.png" id="1_un30v"]
[sub_resource type="CircleShape2D" id="CircleShape2D_srlvs"]
radius = 5.0
radius = 6.0
[node name="Ball" type="Area2D"]
[node name="Ball" type="CharacterBody2D"]
z_index = 1
collision_layer = 8
collision_mask = 7
script = ExtResource("1_8tu7d")
[node name="Sprite2D" type="Sprite2D" parent="."]
texture = ExtResource("1_un30v")

View file

@ -143,6 +143,8 @@ _data = {
size = Vector2(17, 10)
[node name="Enemy" type="CharacterBody2D"]
collision_layer = 2
collision_mask = 13
script = ExtResource("1_2uhn6")
[node name="Sprite2D" type="Sprite2D" parent="."]

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=12 format=3 uid="uid://b51tdt5kunai"]
[gd_scene load_steps=13 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"]
@ -8,6 +8,7 @@
[ext_resource type="Script" path="res://scripts/enemy/behavior_tree/wait_action.gd" id="6_eyknc"]
[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/move_to_destination_action.gd" id="11_tjc85"]
@ -37,6 +38,9 @@ script = ExtResource("2_80fm4")
[node name="CanThrowBall" type="Node" parent="MainSelector/ThrowBallSequence"]
script = ExtResource("7_k5qlq")
[node name="GetRandomTarget" type="Node" parent="MainSelector/ThrowBallSequence"]
script = ExtResource("8_y68xp")
[node name="ThrowBall" type="Node" parent="MainSelector/ThrowBallSequence"]
script = ExtResource("8_wytqf")

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=16 format=3 uid="uid://ba1t35yyot4jl"]
[gd_scene load_steps=17 format=3 uid="uid://ba1t35yyot4jl"]
[ext_resource type="Texture2D" uid="uid://bqkvmyqo86dtj" path="res://art/characters/Owlet_Monster_Walk_6.png" id="1_e23l4"]
[ext_resource type="Script" path="res://scripts/player/player.gd" id="1_fmx2p"]
@ -8,6 +8,7 @@
[ext_resource type="Script" path="res://scripts/state_machine/state_machine.gd" id="6_hl63m"]
[ext_resource type="Script" path="res://scripts/player/states/player_idle_state.gd" id="7_0nfrc"]
[ext_resource type="Script" path="res://scripts/player/states/player_walk_state.gd" id="7_gcd3q"]
[ext_resource type="Script" path="res://scripts/player/states/player_throw_state.gd" id="9_atm3r"]
[sub_resource type="Animation" id="Animation_rh7n7"]
length = 0.001
@ -97,7 +98,6 @@ tracks/2/keys = {
[sub_resource type="Animation" id="Animation_gswgu"]
resource_name = "throw"
length = 0.4
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
@ -186,14 +186,15 @@ _data = {
}
[sub_resource type="RectangleShape2D" id="RectangleShape2D_hocsq"]
size = Vector2(21, 7.5)
size = Vector2(21, 10)
[node name="Player" type="CharacterBody2D"]
collision_mask = 14
script = ExtResource("1_fmx2p")
[node name="Sprite2D" type="Sprite2D" parent="."]
position = Vector2(0, -16)
texture = ExtResource("4_orj3a")
texture = ExtResource("5_2s1mg")
hframes = 4
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
@ -203,7 +204,15 @@ libraries = {
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
y_sort_enabled = true
position = Vector2(-2.5, -3.75)
position = Vector2(-2.5, -5)
shape = SubResource("RectangleShape2D_hocsq")
[node name="Area2D" type="Area2D" parent="."]
collision_mask = 8
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
y_sort_enabled = true
position = Vector2(-2.5, -5)
shape = SubResource("RectangleShape2D_hocsq")
[node name="StateMachine" type="Node" parent="." node_paths=PackedStringArray("state")]
@ -215,3 +224,10 @@ script = ExtResource("7_0nfrc")
[node name="Walk" type="Node" parent="StateMachine"]
script = ExtResource("7_gcd3q")
[node name="Throw" type="Node" parent="StateMachine"]
script = ExtResource("9_atm3r")
[connection signal="collide_with_ball" from="." to="StateMachine/Idle" method="_on_player_collide_with_ball"]
[connection signal="animation_finished" from="AnimationPlayer" to="StateMachine/Throw" method="_on_animation_player_animation_finished"]
[connection signal="body_entered" from="Area2D" to="." method="_on_area_2d_body_entered"]