fix: configurable min frog jump height checks
This commit is contained in:
parent
100c9b547a
commit
79e0fe4a2e
@ -336,7 +336,11 @@ func correct_jump_direction(v: Vector2) -> Vector2:
|
|||||||
# Cast a ray to the highest point of the jump
|
# Cast a ray to the highest point of the jump
|
||||||
# Check the highest point for collision
|
# Check the highest point for collision
|
||||||
# Calculate safe jump height and then a safe jump velocity
|
# Calculate safe jump height and then a safe jump velocity
|
||||||
func consider_jump_headspace(v: Vector2) -> Vector2:
|
# Returns 0,0 if theres no headspace
|
||||||
|
func consider_jump_headspace(v: Vector2, recursive_check_count = 0, max_checks = 2) -> Vector2:
|
||||||
|
if recursive_check_count >= max_checks:
|
||||||
|
print("Frog has no safe headspace")
|
||||||
|
return Vector2(0,0)
|
||||||
var height = calculate_jump_height(v)
|
var height = calculate_jump_height(v)
|
||||||
var distance = calculate_jump_distance(v)
|
var distance = calculate_jump_distance(v)
|
||||||
var angle = (v * get_facing_direction()).angle()
|
var angle = (v * get_facing_direction()).angle()
|
||||||
@ -348,14 +352,13 @@ func consider_jump_headspace(v: Vector2) -> Vector2:
|
|||||||
var target_height = collision_point.y - (feeler_raycast.global_position.y - 23)
|
var target_height = collision_point.y - (feeler_raycast.global_position.y - 23)
|
||||||
# print(feeler_raycast.global_position)
|
# print(feeler_raycast.global_position)
|
||||||
var new_angle = angle * (0.75 if target_height > -26 else 0.95)
|
var new_angle = angle * (0.75 if target_height > -26 else 0.95)
|
||||||
var new_distance = default_jump_distance * (0.66 if target_height < -26 else 0.75)
|
var new_distance = abs(distance) * (0.66 if target_height < -26 else 0.75)
|
||||||
v = velocity_for_jump_distance(new_distance, abs(new_angle))
|
v = velocity_for_jump_distance(new_distance, abs(new_angle))
|
||||||
v = correct_jump_direction(v)
|
v = correct_jump_direction(v)
|
||||||
height = calculate_jump_height(v) * -1
|
height = calculate_jump_height(v) * -1
|
||||||
distance = calculate_jump_distance(v) * get_facing_direction()
|
distance = calculate_jump_distance(v) * get_facing_direction()
|
||||||
if(height < target_height && can_reverse_facing_direction()):
|
if(height < target_height && can_reverse_facing_direction()):
|
||||||
print("no safe height for frog jump")
|
v = consider_jump_headspace(v, recursive_check_count + 1)
|
||||||
return Vector2(0,0)
|
|
||||||
return v
|
return v
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -63,10 +63,10 @@ drag_margin_top = 0.1
|
|||||||
drag_margin_bottom = 0.1
|
drag_margin_bottom = 0.1
|
||||||
|
|
||||||
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
|
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
|
||||||
frame = 1
|
frame = 7
|
||||||
|
|
||||||
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
|
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
|
||||||
frame = 0
|
frame = 6
|
||||||
|
|
||||||
[node name="Blobby" parent="." instance=ExtResource( 8 )]
|
[node name="Blobby" parent="." instance=ExtResource( 8 )]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|||||||
@ -80,10 +80,10 @@ wait_time = 20.0
|
|||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|
||||||
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
|
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
|
||||||
frame = 8
|
frame = 1
|
||||||
|
|
||||||
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
|
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
|
||||||
frame = 7
|
frame = 0
|
||||||
|
|
||||||
[node name="Blobby" parent="." instance=ExtResource( 10 )]
|
[node name="Blobby" parent="." instance=ExtResource( 10 )]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user