fix: flyer AI tweaked to be less unsure, higher default jumps

This commit is contained in:
Jakob Feldmann 2023-04-16 23:50:11 +02:00
parent 73b6f64f8e
commit 34e1427334
4 changed files with 10 additions and 13 deletions

View File

@ -26,12 +26,12 @@ var init_acceleration_force := {
# Oriented around deltas of 0.0166666...s # Oriented around deltas of 0.0166666...s
# newtonmeters is the unit # newtonmeters is the unit
var acceleration_force := { var acceleration_force := {
"walk": Vector2(1800, 1233), "walk": Vector2(1800, 1300),
"fall": Vector2(2000, 0), "fall": Vector2(2000, 0),
"jump": Vector2(2000, 0), "jump": Vector2(2000, 0),
"idle": Vector2(1800, 1233), "idle": Vector2(1800, 1233),
"duck": Vector2(500, 1400), "duck": Vector2(500, 1300),
"run": Vector2(2500, 1290), "run": Vector2(2500, 1400),
"walljump": Vector2(600, 1050), "walljump": Vector2(600, 1050),
"air_strafe": Vector2(333, 2000) "air_strafe": Vector2(333, 2000)
} }

View File

@ -24,6 +24,7 @@ export var max_speed := 90
export var weight := 0.15 export var weight := 0.15
var path_direction: Vector2 = Vector2() var path_direction: Vector2 = Vector2()
var previous_direction := Vector2()
var target: Object = null var target: Object = null
var patrol_waypoints := [] var patrol_waypoints := []
var patrol_waypoint_index := 0 var patrol_waypoint_index := 0
@ -37,7 +38,7 @@ var detect_timer := 0.0
func _ready(): func _ready():
spawn_avoidance_raycasts(32, 24) spawn_avoidance_raycasts(16, 20)
target_lost_timer = Timer.new() target_lost_timer = Timer.new()
target_lost_timer.set_one_shot(true) target_lost_timer.set_one_shot(true)
target_lost_timer.connect("timeout", self, "lose_target") target_lost_timer.connect("timeout", self, "lose_target")
@ -45,7 +46,7 @@ func _ready():
update_navigation_timer = Timer.new() update_navigation_timer = Timer.new()
update_navigation_timer.connect("timeout", self, "update_navigation") update_navigation_timer.connect("timeout", self, "update_navigation")
add_child(update_navigation_timer) add_child(update_navigation_timer)
update_navigation_timer.start(0.5) update_navigation_timer.start(0.3)
# TODO Hat immer den Spawn im Patrolpath # TODO Hat immer den Spawn im Patrolpath
patrol_waypoints.append(global_position) patrol_waypoints.append(global_position)
for waypoint in $PatrolPath.get_children(): for waypoint in $PatrolPath.get_children():
@ -104,7 +105,8 @@ func detect_player() -> void:
func execute_movement(delta: float) -> void: func execute_movement(delta: float) -> void:
detect_timer += delta 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 orientation.cast_to = Vector2(sign(next_direction.x),0)*50
var avoidance_obstacle_distance = average_collision_vector(avoidance_raycasts) var avoidance_obstacle_distance = average_collision_vector(avoidance_raycasts)
next_direction = next_direction.normalized() + avoidance_obstacle_distance.rotated(PI).normalized() next_direction = next_direction.normalized() + avoidance_obstacle_distance.rotated(PI).normalized()

View File

@ -197,7 +197,6 @@ collision_layer = 258
collision_mask = 25 collision_mask = 25
script = ExtResource( 1 ) script = ExtResource( 1 )
vision_distance = 8.0 vision_distance = 8.0
blindspot_angle = 30
loose_target_seconds = 5.0 loose_target_seconds = 5.0
patrolling = true patrolling = true
acceleration = 80 acceleration = 80
@ -259,9 +258,8 @@ collide_with_areas = true
shape = SubResource( 1 ) shape = SubResource( 1 )
[node name="NavigationAgent2D" type="NavigationAgent2D" parent="."] [node name="NavigationAgent2D" type="NavigationAgent2D" parent="."]
path_desired_distance = 4.0 path_desired_distance = 8.0
target_desired_distance = 8.0 target_desired_distance = 8.0
path_max_distance = 50.0
[node name="cshape" type="Node2D" parent="."] [node name="cshape" type="Node2D" parent="."]
position = Vector2( 0, -3.8147e-06 ) position = Vector2( 0, -3.8147e-06 )

View File

@ -43,11 +43,8 @@ wait_time = 20.0
[node name="BlobbyCam" parent="." instance=ExtResource( 6 )] [node name="BlobbyCam" parent="." instance=ExtResource( 6 )]
drag_margin_bottom = 0.3 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"] [node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
frame = 8 frame = 0
[node name="Blobby" parent="." instance=ExtResource( 12 )] [node name="Blobby" parent="." instance=ExtResource( 12 )]
unique_name_in_owner = true unique_name_in_owner = true