fix: Adjusted the stomping mechanic
Instead of checking the height of the entry of blobbys hitbox in the enemy stomping area, the success of the stomp now depends on the angle of entry into the stomping area.
This commit is contained in:
parent
650b71e289
commit
73b6f64f8e
@ -61,7 +61,6 @@ GlobalState="*res://src/Autoload/GlobalState.tscn"
|
|||||||
[debug]
|
[debug]
|
||||||
|
|
||||||
settings/fps/force_fps=60
|
settings/fps/force_fps=60
|
||||||
settings/stdout/print_fps=true
|
|
||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
|
|||||||
@ -140,9 +140,6 @@ func _get_transition(delta):
|
|||||||
# + String(round(parent.velocity.y / 10))
|
# + String(round(parent.velocity.y / 10))
|
||||||
)
|
)
|
||||||
var new_state
|
var new_state
|
||||||
print(was_coyote_hanging)
|
|
||||||
print("timer")
|
|
||||||
print($CoyoteTimer.wait_time)
|
|
||||||
if !parent.is_on_floor():
|
if !parent.is_on_floor():
|
||||||
if parent.velocity.y < -1:
|
if parent.velocity.y < -1:
|
||||||
was_coyote_hanging = false
|
was_coyote_hanging = false
|
||||||
|
|||||||
@ -24,4 +24,4 @@ func _physics_process(delta: float) -> void:
|
|||||||
# velocity
|
# velocity
|
||||||
var v = Vector2(velocity.x * movement, 0)
|
var v = Vector2(velocity.x * movement, 0)
|
||||||
time += delta
|
time += delta
|
||||||
move_and_slide_with_snap(v.rotated(rotation), snap.rotated(rotation), FLOOR_NORMAL, false, 4, PI)
|
move_and_slide_with_snap(v.rotated(rotation), snap.rotated(rotation), FLOOR_NORMAL, false, 4, PI, false)
|
||||||
|
|||||||
@ -4,16 +4,16 @@
|
|||||||
[ext_resource path="res://src/Actors/Enemies/Beings/Caterpillar.gd" type="Script" id=2]
|
[ext_resource path="res://src/Actors/Enemies/Beings/Caterpillar.gd" type="Script" id=2]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 2.72463, 1.17848 )
|
extents = Vector2( 2.64025, 1.15615 )
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=2]
|
[sub_resource type="RectangleShape2D" id=2]
|
||||||
extents = Vector2( 18.75, 6.38067 )
|
extents = Vector2( 15, 6 )
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=3]
|
[sub_resource type="RectangleShape2D" id=3]
|
||||||
extents = Vector2( 14.563, 9.38461 )
|
extents = Vector2( 15, 12 )
|
||||||
|
|
||||||
[node name="Caterpillar" type="KinematicBody2D" groups=["harmful"]]
|
[node name="Caterpillar" type="KinematicBody2D" groups=["harmful"]]
|
||||||
scale = Vector2( 0.8, 0.5 )
|
scale = Vector2( 0.747749, 0.572926 )
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
collision_mask = 9
|
collision_mask = 9
|
||||||
script = ExtResource( 2 )
|
script = ExtResource( 2 )
|
||||||
@ -30,8 +30,8 @@ rect = Rect2( -89, -10, 2, 20 )
|
|||||||
process_parent = true
|
process_parent = true
|
||||||
physics_process_parent = true
|
physics_process_parent = true
|
||||||
|
|
||||||
[node name="EnemyBody" type="CollisionShape2D" parent="." groups=["harmful"]]
|
[node name="EnemyBody" type="CollisionShape2D" parent="."]
|
||||||
position = Vector2( 0, 6 )
|
position = Vector2( 6.70552e-07, 6.11815 )
|
||||||
scale = Vector2( 5.68128, 5.29182 )
|
scale = Vector2( 5.68128, 5.29182 )
|
||||||
shape = SubResource( 1 )
|
shape = SubResource( 1 )
|
||||||
|
|
||||||
@ -61,21 +61,23 @@ collision_mask = 8
|
|||||||
|
|
||||||
[node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]]
|
[node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]]
|
||||||
modulate = Color( 0, 0.0392157, 1, 1 )
|
modulate = Color( 0, 0.0392157, 1, 1 )
|
||||||
|
light_mask = 0
|
||||||
position = Vector2( 0, -6.44095 )
|
position = Vector2( 0, -6.44095 )
|
||||||
collision_layer = 2
|
collision_layer = 2
|
||||||
input_pickable = false
|
input_pickable = false
|
||||||
monitorable = false
|
monitorable = false
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
|
||||||
position = Vector2( 0, 0.0602803 )
|
position = Vector2( 0, 0.440949 )
|
||||||
shape = SubResource( 2 )
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
[node name="EnemySkin" type="Area2D" parent="." groups=["player"]]
|
[node name="EnemySkin" type="Area2D" parent="." groups=["player"]]
|
||||||
process_priority = -1
|
process_priority = -1
|
||||||
|
collision_layer = 2
|
||||||
collision_mask = 126
|
collision_mask = 126
|
||||||
|
|
||||||
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
|
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
|
||||||
position = Vector2( 0, 3.76 )
|
position = Vector2( -5.54991e-05, 0 )
|
||||||
scale = Vector2( 1.03, 1.04 )
|
scale = Vector2( 1.03, 1.04 )
|
||||||
shape = SubResource( 3 )
|
shape = SubResource( 3 )
|
||||||
|
|
||||||
|
|||||||
@ -2,17 +2,22 @@ extends Actor
|
|||||||
class_name Enemy
|
class_name Enemy
|
||||||
|
|
||||||
func _on_StompDetector_body_entered(body: Node) -> void:
|
func _on_StompDetector_body_entered(body: Node) -> void:
|
||||||
if body.global_position.y > get_node("StompDetector").global_position.y:
|
if !body.is_in_group("player"):
|
||||||
return
|
return
|
||||||
if body.is_in_group("player"):
|
var incoming_vel_vector: Vector2 = body.velocity.normalized()
|
||||||
signalManager.emit_signal("got_stomped")
|
print(rad2deg(abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation)))))
|
||||||
remove_from_group("harmful")
|
if abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation))) > deg2rad(40):
|
||||||
$StompDetector.remove_from_group("weakpoint")
|
print("too shallow entry")
|
||||||
get_node("EnemyBody").disabled = true
|
return
|
||||||
die()
|
signalManager.emit_signal("got_stomped")
|
||||||
|
remove_from_group("harmful")
|
||||||
|
$StompDetector.remove_from_group("weakpoint")
|
||||||
|
get_node("EnemyBody").disabled = true
|
||||||
|
die()
|
||||||
|
|
||||||
func die() -> void:
|
func die() -> void:
|
||||||
queue_free()
|
queue_free()
|
||||||
|
# TODO make batterr
|
||||||
levelState.kills += 1
|
levelState.kills += 1
|
||||||
|
|
||||||
func _on_EnemySkin_area_entered(area:Area2D) -> void:
|
func _on_EnemySkin_area_entered(area:Area2D) -> void:
|
||||||
|
|||||||
@ -87,7 +87,7 @@ func hunting() -> Vector2:
|
|||||||
func detect_player() -> void:
|
func detect_player() -> void:
|
||||||
var player
|
var player
|
||||||
if(players.empty()):
|
if(players.empty()):
|
||||||
print("no player found")
|
# print("no player found")
|
||||||
return
|
return
|
||||||
player = players[0]
|
player = players[0]
|
||||||
#TODO Depends on height of blobby sprite since blobbys bottom and not his middle is on y=0
|
#TODO Depends on height of blobby sprite since blobbys bottom and not his middle is on y=0
|
||||||
@ -98,7 +98,7 @@ func detect_player() -> void:
|
|||||||
if(abs(ray_angle_to_facing) < PI/2-deg2rad(blindspot_angle) && collider != null && collider.is_in_group("player")):
|
if(abs(ray_angle_to_facing) < PI/2-deg2rad(blindspot_angle) && collider != null && collider.is_in_group("player")):
|
||||||
target_lost_timer.stop()
|
target_lost_timer.stop()
|
||||||
target = collider
|
target = collider
|
||||||
print("target found")
|
# print("target found")
|
||||||
elif(target != null && target_lost_timer.is_stopped()):
|
elif(target != null && target_lost_timer.is_stopped()):
|
||||||
target_lost_timer.start(loose_target_seconds)
|
target_lost_timer.start(loose_target_seconds)
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ func check_feeler(v: Vector2, _offset = Vector2(0,0)) -> Object:
|
|||||||
return feeler_raycast.get_collider()
|
return feeler_raycast.get_collider()
|
||||||
|
|
||||||
func lose_target() -> void:
|
func lose_target() -> void:
|
||||||
print("flyer target lost")
|
# print("flyer target lost")
|
||||||
target = null
|
target = null
|
||||||
|
|
||||||
func update_navigation() -> void:
|
func update_navigation() -> void:
|
||||||
|
|||||||
@ -69,15 +69,18 @@ func bind_to_anchor(anchor_node: Node2D, radius: float ) -> void:
|
|||||||
|
|
||||||
|
|
||||||
func _on_StompDetector_body_entered(body: Node) -> void:
|
func _on_StompDetector_body_entered(body: Node) -> void:
|
||||||
if body.global_position.y - 1 > get_node("StompDetector").global_position.y:
|
if !body.is_in_group("player"):
|
||||||
return
|
return
|
||||||
if body.is_in_group("player") && !is_hurt:
|
var incoming_vel_vector: Vector2 = body.velocity.normalized()
|
||||||
remove_from_group("harmful")
|
print(rad2deg(abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation)))))
|
||||||
$StompDetector.remove_from_group("weakpoint")
|
if abs(incoming_vel_vector.angle_to(Vector2.DOWN.rotated(rotation))) > deg2rad(50):
|
||||||
signalManager.emit_signal("got_stomped")
|
print("too shallow entry")
|
||||||
is_hurt = true
|
return
|
||||||
$HurtTimer.start()
|
signalManager.emit_signal("got_stomped")
|
||||||
$FrogSprite.material = invincible_shader
|
remove_from_group("harmful")
|
||||||
|
$StompDetector.remove_from_group("weakpoint")
|
||||||
|
get_node("EnemyBody").disabled = true
|
||||||
|
die()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -217,7 +220,7 @@ func detect_food() -> void:
|
|||||||
func detect_player() -> void:
|
func detect_player() -> void:
|
||||||
var player
|
var player
|
||||||
if(players.empty()):
|
if(players.empty()):
|
||||||
print("no player found")
|
# print("no player found")
|
||||||
return
|
return
|
||||||
player = players[0]
|
player = players[0]
|
||||||
#TODO Depends on height of blobby sprite since blobbys bottom and not his middle is on y=0
|
#TODO Depends on height of blobby sprite since blobbys bottom and not his middle is on y=0
|
||||||
@ -239,7 +242,7 @@ func sleeping() -> Vector2:
|
|||||||
|
|
||||||
|
|
||||||
func loose_target() -> void:
|
func loose_target() -> void:
|
||||||
print("frog target lost")
|
# print("frog target lost")
|
||||||
target = null
|
target = null
|
||||||
food_target = null
|
food_target = null
|
||||||
|
|
||||||
@ -307,7 +310,7 @@ func consider_jump_headspace(v: Vector2) -> Vector2:
|
|||||||
if(height_collider != null):
|
if(height_collider != null):
|
||||||
var collision_point = feeler_raycast.get_collision_point()
|
var collision_point = feeler_raycast.get_collision_point()
|
||||||
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 = default_jump_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))
|
||||||
@ -496,4 +499,5 @@ func get_facing_direction() -> float:
|
|||||||
|
|
||||||
func _on_HurtTimer_timeout() -> void:
|
func _on_HurtTimer_timeout() -> void:
|
||||||
is_hurt = false
|
is_hurt = false
|
||||||
|
add_to_group("harmful")
|
||||||
$FrogSprite.material = null
|
$FrogSprite.material = null
|
||||||
|
|||||||
@ -36,10 +36,10 @@ unique_name_in_owner = true
|
|||||||
drag_margin_bottom = 0.3
|
drag_margin_bottom = 0.3
|
||||||
|
|
||||||
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
|
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
|
||||||
frame = 5
|
frame = 10
|
||||||
|
|
||||||
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
|
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
|
||||||
frame = 5
|
frame = 10
|
||||||
|
|
||||||
[node name="Blobby" parent="." instance=ExtResource( 8 )]
|
[node name="Blobby" parent="." instance=ExtResource( 8 )]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|||||||
@ -44,10 +44,10 @@ unique_name_in_owner = true
|
|||||||
drag_margin_bottom = 0.3
|
drag_margin_bottom = 0.3
|
||||||
|
|
||||||
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
|
[node name="AnimatedSprite" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="4"]
|
||||||
frame = 1
|
frame = 11
|
||||||
|
|
||||||
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
|
[node name="AnimatedSprite2" parent="BlobbyCam/ParallaxBackground/ParallaxLayer5" index="5"]
|
||||||
frame = 1
|
frame = 11
|
||||||
|
|
||||||
[node name="Blobby" parent="." instance=ExtResource( 9 )]
|
[node name="Blobby" parent="." instance=ExtResource( 9 )]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user