From 34e1427334e5f8f2da404674a44c4e515a3ce113 Mon Sep 17 00:00:00 2001 From: Jakob Feldmann Date: Sun, 16 Apr 2023 23:50:11 +0200 Subject: [PATCH] fix: flyer AI tweaked to be less unsure, higher default jumps --- src/Actors/Actor.gd | 6 +++--- src/Actors/Enemies/Beings/Flyer.gd | 8 +++++--- src/Actors/Enemies/Beings/Flyer.tscn | 4 +--- src/Levels/x01 Level.tscn | 5 +---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/Actors/Actor.gd b/src/Actors/Actor.gd index 86d947d..44b95e6 100644 --- a/src/Actors/Actor.gd +++ b/src/Actors/Actor.gd @@ -26,12 +26,12 @@ var init_acceleration_force := { # Oriented around deltas of 0.0166666...s # newtonmeters is the unit var acceleration_force := { - "walk": Vector2(1800, 1233), + "walk": Vector2(1800, 1300), "fall": Vector2(2000, 0), "jump": Vector2(2000, 0), "idle": Vector2(1800, 1233), - "duck": Vector2(500, 1400), - "run": Vector2(2500, 1290), + "duck": Vector2(500, 1300), + "run": Vector2(2500, 1400), "walljump": Vector2(600, 1050), "air_strafe": Vector2(333, 2000) } diff --git a/src/Actors/Enemies/Beings/Flyer.gd b/src/Actors/Enemies/Beings/Flyer.gd index 41b8961..c99808c 100644 --- a/src/Actors/Enemies/Beings/Flyer.gd +++ b/src/Actors/Enemies/Beings/Flyer.gd @@ -24,6 +24,7 @@ export var max_speed := 90 export var weight := 0.15 var path_direction: Vector2 = Vector2() +var previous_direction := Vector2() var target: Object = null var patrol_waypoints := [] var patrol_waypoint_index := 0 @@ -37,7 +38,7 @@ var detect_timer := 0.0 func _ready(): - spawn_avoidance_raycasts(32, 24) + spawn_avoidance_raycasts(16, 20) target_lost_timer = Timer.new() target_lost_timer.set_one_shot(true) target_lost_timer.connect("timeout", self, "lose_target") @@ -45,7 +46,7 @@ func _ready(): update_navigation_timer = Timer.new() update_navigation_timer.connect("timeout", self, "update_navigation") add_child(update_navigation_timer) - update_navigation_timer.start(0.5) + update_navigation_timer.start(0.3) # TODO Hat immer den Spawn im Patrolpath patrol_waypoints.append(global_position) for waypoint in $PatrolPath.get_children(): @@ -104,7 +105,8 @@ func detect_player() -> void: func execute_movement(delta: float) -> void: detect_timer += delta - var next_direction = path_direction - global_position + var next_direction = lerp(previous_direction, path_direction - global_position, 0.5) + previous_direction = next_direction orientation.cast_to = Vector2(sign(next_direction.x),0)*50 var avoidance_obstacle_distance = average_collision_vector(avoidance_raycasts) next_direction = next_direction.normalized() + avoidance_obstacle_distance.rotated(PI).normalized() diff --git a/src/Actors/Enemies/Beings/Flyer.tscn b/src/Actors/Enemies/Beings/Flyer.tscn index a76272a..fc4aa5c 100644 --- a/src/Actors/Enemies/Beings/Flyer.tscn +++ b/src/Actors/Enemies/Beings/Flyer.tscn @@ -197,7 +197,6 @@ collision_layer = 258 collision_mask = 25 script = ExtResource( 1 ) vision_distance = 8.0 -blindspot_angle = 30 loose_target_seconds = 5.0 patrolling = true acceleration = 80 @@ -259,9 +258,8 @@ collide_with_areas = true shape = SubResource( 1 ) [node name="NavigationAgent2D" type="NavigationAgent2D" parent="."] -path_desired_distance = 4.0 +path_desired_distance = 8.0 target_desired_distance = 8.0 -path_max_distance = 50.0 [node name="cshape" type="Node2D" parent="."] position = Vector2( 0, -3.8147e-06 ) diff --git a/src/Levels/x01 Level.tscn b/src/Levels/x01 Level.tscn index d801678..cb8562e 100644 --- a/src/Levels/x01 Level.tscn +++ b/src/Levels/x01 Level.tscn @@ -43,11 +43,8 @@ wait_time = 20.0 [node name="BlobbyCam" parent="." instance=ExtResource( 6 )] drag_margin_bottom = 0.3 -[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"] -frame = 1 - [node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"] -frame = 8 +frame = 0 [node name="Blobby" parent="." instance=ExtResource( 12 )] unique_name_in_owner = true