diff --git a/demo/ai/trees/waypoints.tres b/demo/ai/trees/waypoints.tres index 32a319a..c056b64 100644 --- a/demo/ai/trees/waypoints.tres +++ b/demo/ai/trees/waypoints.tres @@ -1,4 +1,4 @@ -[gd_resource type="BehaviorTree" load_steps=9 format=3 uid="uid://cjkqi41oagagd"] +[gd_resource type="BehaviorTree" load_steps=10 format=3 uid="uid://cjkqi41oagagd"] [ext_resource type="Script" path="res://ai/tasks/arrive_pos.gd" id="1_rhs33"] [ext_resource type="Script" path="res://ai/tasks/play_animation.gd" id="2_dg0ss"] @@ -14,8 +14,11 @@ script = ExtResource("2_dg0ss") animation_name = "bounce" animation_player = NodePath("AnimationPlayer") +[sub_resource type="BTWait" id="BTWait_qs55a"] +duration = 0.1 + [sub_resource type="BTSequence" id="BTSequence_a2ng0"] -children = [SubResource("BTAction_3xal7"), SubResource("BTAction_yq1vl")] +children = [SubResource("BTAction_3xal7"), SubResource("BTAction_yq1vl"), SubResource("BTWait_qs55a")] [sub_resource type="BTForEach" id="BTForEach_0cp04"] children = [SubResource("BTSequence_a2ng0")] diff --git a/demo/tests/waypoints/test_waypoints.gd b/demo/examples/waypoints/example_waypoints.gd similarity index 72% rename from demo/tests/waypoints/test_waypoints.gd rename to demo/examples/waypoints/example_waypoints.gd index f1c8d87..19d153d 100644 --- a/demo/tests/waypoints/test_waypoints.gd +++ b/demo/examples/waypoints/example_waypoints.gd @@ -1,5 +1,5 @@ #* -#* test_waypoints.gd +#* example_waypoints.gd #* ============================================================================= #* Copyright 2021-2023 Serhii Snitsaruk #* @@ -11,18 +11,18 @@ extends Node2D -@onready var agent: CharacterBody2D = $Agent -@onready var agent_2: CharacterBody2D = $Agent2 +@onready var agent1: CharacterBody2D = $Agent +@onready var agent2: CharacterBody2D = $Agent2 func _ready() -> void: var waypoints: Array[Node] = $Waypoints.get_children() for wp in waypoints: - agent.add_waypoint(wp.global_position) + agent1.add_waypoint(wp.global_position) waypoints.reverse() for wp in waypoints: - agent_2.add_waypoint(wp.global_position) + agent2.add_waypoint(wp.global_position) diff --git a/demo/examples/waypoints/example_waypoints.tscn b/demo/examples/waypoints/example_waypoints.tscn new file mode 100644 index 0000000..2bb4425 --- /dev/null +++ b/demo/examples/waypoints/example_waypoints.tscn @@ -0,0 +1,30 @@ +[gd_scene load_steps=4 format=3 uid="uid://p5i7fdku3hqs"] + +[ext_resource type="Script" path="res://examples/waypoints/example_waypoints.gd" id="1_d4sso"] +[ext_resource type="Script" path="res://examples/waypoints/waypoint_marker.gd" id="2_l26sl"] +[ext_resource type="PackedScene" uid="uid://c26b8c8dndtop" path="res://examples/waypoints/patrolling_agent.tscn" id="3_t4qgi"] + +[node name="ExampleWaypoints" type="Node2D"] +script = ExtResource("1_d4sso") + +[node name="Waypoints" type="Node2D" parent="."] + +[node name="WP1" type="Marker2D" parent="Waypoints"] +position = Vector2(258, 126) +script = ExtResource("2_l26sl") + +[node name="WP2" type="Marker2D" parent="Waypoints"] +position = Vector2(830, 131) +script = ExtResource("2_l26sl") + +[node name="WP3" type="Marker2D" parent="Waypoints"] +position = Vector2(534, 492) +script = ExtResource("2_l26sl") + +[node name="Agent" parent="." instance=ExtResource("3_t4qgi")] +y_sort_enabled = true +position = Vector2(57, 59) + +[node name="Agent2" parent="." instance=ExtResource("3_t4qgi")] +y_sort_enabled = true +position = Vector2(316, 590) diff --git a/demo/tests/waypoints/Agent.gd b/demo/examples/waypoints/patrolling_agent.gd similarity index 96% rename from demo/tests/waypoints/Agent.gd rename to demo/examples/waypoints/patrolling_agent.gd index cfc7bd0..04ae8c2 100644 --- a/demo/tests/waypoints/Agent.gd +++ b/demo/examples/waypoints/patrolling_agent.gd @@ -1,5 +1,5 @@ #* -#* Agent.gd +#* patrolling_agent.gd #* ============================================================================= #* Copyright 2021-2023 Serhii Snitsaruk #* diff --git a/demo/tests/waypoints/Agent.tscn b/demo/examples/waypoints/patrolling_agent.tscn similarity index 75% rename from demo/tests/waypoints/Agent.tscn rename to demo/examples/waypoints/patrolling_agent.tscn index 51a2ef7..41d7661 100644 --- a/demo/tests/waypoints/Agent.tscn +++ b/demo/examples/waypoints/patrolling_agent.tscn @@ -1,8 +1,8 @@ [gd_scene load_steps=7 format=3 uid="uid://c26b8c8dndtop"] -[ext_resource type="Script" path="res://tests/waypoints/Agent.gd" id="1_1l3ql"] -[ext_resource type="BehaviorTree" uid="uid://cjkqi41oagagd" path="res://ai/trees/waypoints.tres" id="2_ijwrx"] -[ext_resource type="Texture2D" uid="uid://d0mht3ntak7e5" path="res://icon.png" id="2_xqtrc"] +[ext_resource type="Script" path="res://examples/waypoints/patrolling_agent.gd" id="1_5wwhb"] +[ext_resource type="BehaviorTree" uid="uid://cjkqi41oagagd" path="res://ai/trees/waypoints.tres" id="2_66y4v"] +[ext_resource type="Texture2D" uid="uid://d0mht3ntak7e5" path="res://icon.png" id="3_j5bxx"] [sub_resource type="Animation" id="Animation_5id00"] length = 0.001 @@ -21,6 +21,7 @@ tracks/0/keys = { [sub_resource type="Animation" id="Animation_4w16c"] resource_name = "bounce" +length = 0.6 tracks/0/type = "value" tracks/0/imported = false tracks/0/enabled = true @@ -28,8 +29,8 @@ tracks/0/path = NodePath("Sprite2D:scale") tracks/0/interp = 1 tracks/0/loop_wrap = true tracks/0/keys = { -"times": PackedFloat32Array(0, 0.5, 1), -"transitions": PackedFloat32Array(1, 1, 1), +"times": PackedFloat32Array(0, 0.3, 0.6), +"transitions": PackedFloat32Array(0.5, 2, 1), "update": 0, "values": [Vector2(1, 1), Vector2(2, 2), Vector2(1, 1)] } @@ -40,17 +41,17 @@ _data = { "bounce": SubResource("Animation_4w16c") } -[node name="Agent" type="CharacterBody2D"] -script = ExtResource("1_1l3ql") +[node name="PatrollingAgent" type="CharacterBody2D"] +script = ExtResource("1_5wwhb") [node name="BTPlayer" type="BTPlayer" parent="."] -behavior_tree = ExtResource("2_ijwrx") +behavior_tree = ExtResource("2_66y4v") _blackboard_data = { "speed": 200.0 } [node name="Sprite2D" type="Sprite2D" parent="."] -texture = ExtResource("2_xqtrc") +texture = ExtResource("3_j5bxx") [node name="AnimationPlayer" type="AnimationPlayer" parent="."] libraries = { diff --git a/demo/tests/waypoints/waypoint_marker.gd b/demo/examples/waypoints/waypoint_marker.gd similarity index 100% rename from demo/tests/waypoints/waypoint_marker.gd rename to demo/examples/waypoints/waypoint_marker.gd diff --git a/demo/icon.png.import b/demo/icon.png.import index b587c2e..977b708 100644 --- a/demo/icon.png.import +++ b/demo/icon.png.import @@ -16,9 +16,9 @@ dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.cte [params] compress/mode=0 +compress/high_quality=false compress/lossy_quality=0.7 compress/hdr_compression=1 -compress/bptc_ldr=0 compress/normal_map=0 compress/channel_pack=0 mipmaps/generate=false diff --git a/demo/project.godot b/demo/project.godot index 4101572..61bb6be 100644 --- a/demo/project.godot +++ b/demo/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="LimboAI Test" -run/main_scene="res://tests/waypoints/test_waypoints.tscn" +run/main_scene="res://examples/waypoints/example_waypoints.tscn" config/features=PackedStringArray("4.1") config/icon="res://icon.png" diff --git a/demo/tests/waypoints/test_waypoints.tscn b/demo/tests/waypoints/test_waypoints.tscn deleted file mode 100644 index 275b0d3..0000000 --- a/demo/tests/waypoints/test_waypoints.tscn +++ /dev/null @@ -1,30 +0,0 @@ -[gd_scene load_steps=4 format=3 uid="uid://p5i7fdku3hqs"] - -[ext_resource type="PackedScene" uid="uid://c26b8c8dndtop" path="res://tests/waypoints/Agent.tscn" id="1_esee5"] -[ext_resource type="Script" path="res://tests/waypoints/test_waypoints.gd" id="1_kmjjq"] -[ext_resource type="Script" path="res://tests/waypoints/waypoint_marker.gd" id="3_1aub7"] - -[node name="test_waypoints" type="Node2D"] -script = ExtResource("1_kmjjq") - -[node name="Waypoints" type="Node2D" parent="."] - -[node name="WP1" type="Marker2D" parent="Waypoints"] -position = Vector2(258, 126) -script = ExtResource("3_1aub7") - -[node name="WP2" type="Marker2D" parent="Waypoints"] -position = Vector2(830, 131) -script = ExtResource("3_1aub7") - -[node name="WP3" type="Marker2D" parent="Waypoints"] -position = Vector2(534, 492) -script = ExtResource("3_1aub7") - -[node name="Agent" parent="." instance=ExtResource("1_esee5")] -y_sort_enabled = true -position = Vector2(57, 59) - -[node name="Agent2" parent="." instance=ExtResource("1_esee5")] -y_sort_enabled = true -position = Vector2(316, 590)