fix: reworked stomping mechanic
This commit is contained in:
parent
403750a9b0
commit
3fd696d988
@ -14,6 +14,11 @@ _global_script_classes=[ {
|
||||
"language": "GDScript",
|
||||
"path": "res://src/Actors/Actor.gd"
|
||||
}, {
|
||||
"base": "Actor",
|
||||
"class": "Enemy",
|
||||
"language": "GDScript",
|
||||
"path": "res://src/Actors/Enemies/Beings/Enemy.gd"
|
||||
}, {
|
||||
"base": "Line2D",
|
||||
"class": "RayCastDebugLines",
|
||||
"language": "GDScript",
|
||||
@ -31,6 +36,7 @@ _global_script_classes=[ {
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"Actor": "",
|
||||
"Enemy": "",
|
||||
"RayCastDebugLines": "",
|
||||
"RayCaster": "",
|
||||
"StateMachine": ""
|
||||
|
||||
@ -9,6 +9,8 @@ const PhysicsConst = preload("res://src/Utilities/Physic/PhysicsConst.gd")
|
||||
const FLOOR_NORMAL := Vector2.UP
|
||||
|
||||
var stomp_feedback := 1200
|
||||
var reset_stomp_time := 0.108
|
||||
var stomp_time := 0.108
|
||||
var inair_velocity := 21
|
||||
var wallslide_threshold := 1000
|
||||
var base_floor_friction := 0.5
|
||||
|
||||
@ -23,41 +23,35 @@ var previous_rotation = 0
|
||||
var snap_possible = true
|
||||
var shielded = false
|
||||
|
||||
# When the Enemy stomp AREA enters the enemy collision area -> stomp
|
||||
func _on_BlobbySkin_area_entered(area: Area2D) -> void:
|
||||
if area.is_in_group("weakpoint"):
|
||||
stomping = true
|
||||
if area.is_in_group("harmful") && !levelState.is_dead:
|
||||
die()
|
||||
if area.is_in_group("pit"):
|
||||
shielded = false
|
||||
die()
|
||||
func execute_movement() -> void:
|
||||
if(levelState.is_dead):
|
||||
return
|
||||
var snap = Vector2.DOWN * 128
|
||||
var center_floor_rot = 0
|
||||
var floor_rot = 0
|
||||
var onfloor = is_on_floor()
|
||||
|
||||
|
||||
# When the Enemy collision BODY enters the enemy collision area -> die
|
||||
func _on_BlobbySkin_body_entered(body: Node) -> void:
|
||||
if body.is_in_group("harmful") && !levelState.is_dead:
|
||||
die()
|
||||
|
||||
|
||||
func _on_JumpBufferTimer_timeout() -> void:
|
||||
jump_buffer_filled = false
|
||||
|
||||
|
||||
func handle_grounded_movement(delta: float, direction: Vector2) -> Vector2:
|
||||
return calculate_grounded_velocity(velocity, delta, direction)
|
||||
|
||||
func handle_jump_movement(delta: float, direction: Vector2) -> Vector2:
|
||||
return calculate_jump_velocity(velocity, delta, direction)
|
||||
|
||||
func handle_duck_movement(delta: float, direction: Vector2) -> Vector2:
|
||||
return calculate_duck_velocity(velocity, delta, direction)
|
||||
|
||||
func handle_fall_movement(delta: float, direction: Vector2) -> Vector2:
|
||||
return calculate_fall_velocity(velocity, delta, direction)
|
||||
|
||||
func handle_wallslide_movement(delta: float, direction: Vector2) -> Vector2:
|
||||
return calculate_wallslide_velocity(velocity, delta, direction)
|
||||
# get rotation of floor, compare collided floor with floor under center
|
||||
if onfloor:
|
||||
# TODO: Problem when correctly rotating?
|
||||
center_floor_rot = $SlopeRaycast.get_collision_normal().rotated(PI/2).angle()
|
||||
floor_rot = get_floor_normal().rotated(PI/2).angle()
|
||||
if(abs(center_floor_rot) > PI/4+0.1):
|
||||
center_floor_rot = floor_rot
|
||||
# snap when on slopes
|
||||
if((abs(floor_rot) > 0.1 || abs(center_floor_rot) > 0.1) && snap_possible):
|
||||
velocity = move_and_slide_with_snap(velocity.rotated(floor_rot),
|
||||
snap, FLOOR_NORMAL, true)
|
||||
# normal slide on flat floor
|
||||
else:
|
||||
velocity = move_and_slide(velocity.rotated(floor_rot),FLOOR_NORMAL)
|
||||
rotation = 0
|
||||
if($SlopeRaycastLeft.is_colliding() && $SlopeRaycastRight.is_colliding() && $SlopeRaycast.is_colliding()):
|
||||
rotation = calculate_slope_rotation(onfloor)
|
||||
# rotate related to floor slope
|
||||
# Convert velocity back to local space.
|
||||
# TODO: Downward velocity should be increased by gravity
|
||||
velocity = velocity.rotated(-floor_rot) if snap_possible else velocity
|
||||
|
||||
|
||||
func calculate_duck_velocity(
|
||||
@ -265,7 +259,10 @@ func calculate_jump_velocity(
|
||||
var additive_jump_force = velocity_jump_boost_ratio * abs(velocity.x) * mass
|
||||
if stomping:
|
||||
additive_jump_force += stomp_feedback / delta
|
||||
stomping = false
|
||||
stomp_time -= delta
|
||||
if stomp_time <= 0:
|
||||
stomp_time = reset_stomp_time
|
||||
stomping = false
|
||||
|
||||
if state != "jump":
|
||||
linear_velocity.y = PhysicsFunc.two_step_euler(
|
||||
@ -275,7 +272,7 @@ func calculate_jump_velocity(
|
||||
delta
|
||||
)
|
||||
|
||||
if !Input.is_action_pressed("jump"):
|
||||
if !Input.is_action_pressed("jump") && !stomping:
|
||||
# Smooth transition from jumping to falling
|
||||
if velocity.y > _gravity * delta * 10:
|
||||
linear_velocity.y += _gravity * delta * 10
|
||||
@ -288,7 +285,7 @@ func calculate_jump_velocity(
|
||||
else:
|
||||
linear_velocity.y += _gravity * delta
|
||||
|
||||
# TODO This poop too
|
||||
# TODO This is poop too
|
||||
if -20 < velocity.x and velocity.x < 20:
|
||||
linear_velocity.x += inair_velocity * direction.x
|
||||
|
||||
@ -370,35 +367,6 @@ func execute_airstrafe(
|
||||
air_strafe_charges -= 1
|
||||
return linear_velocity
|
||||
|
||||
func execute_movement() -> void:
|
||||
if(levelState.is_dead):
|
||||
return
|
||||
var snap = Vector2.DOWN * 128
|
||||
var center_floor_rot = 0
|
||||
var floor_rot = 0
|
||||
var onfloor = is_on_floor()
|
||||
|
||||
# get rotation of floor, compare collided floor with floor under center
|
||||
if onfloor:
|
||||
# TODO: Problem when correctly rotating?
|
||||
center_floor_rot = $SlopeRaycast.get_collision_normal().rotated(PI/2).angle()
|
||||
floor_rot = get_floor_normal().rotated(PI/2).angle()
|
||||
if(abs(center_floor_rot) > PI/4+0.1):
|
||||
center_floor_rot = floor_rot
|
||||
# snap when on slopes
|
||||
if((abs(floor_rot) > 0.1 || abs(center_floor_rot) > 0.1) && snap_possible):
|
||||
velocity = move_and_slide_with_snap(velocity.rotated(floor_rot),
|
||||
snap, FLOOR_NORMAL, true)
|
||||
# normal slide on flat floor
|
||||
else:
|
||||
velocity = move_and_slide(velocity.rotated(floor_rot),FLOOR_NORMAL)
|
||||
rotation = 0
|
||||
if($SlopeRaycastLeft.is_colliding() && $SlopeRaycastRight.is_colliding() && $SlopeRaycast.is_colliding()):
|
||||
rotation = calculate_slope_rotation(onfloor)
|
||||
# rotate related to floor slope
|
||||
# Convert velocity back to local space.
|
||||
# TODO: Downward velocity should be increased by gravity
|
||||
velocity = velocity.rotated(-floor_rot) if snap_possible else velocity
|
||||
|
||||
func calculate_slope_rotation(onfloor: bool) -> float:
|
||||
var angle = 0
|
||||
@ -423,6 +391,10 @@ func calculate_slope_rotation(onfloor: bool) -> float:
|
||||
pass
|
||||
return angle
|
||||
|
||||
# TODO could be expanded with a parameter about what got stomped
|
||||
func stomp() -> void:
|
||||
stomping = true
|
||||
|
||||
func receive_power_up(kind: String) -> void:
|
||||
if kind == "shield":
|
||||
$BubbleShieldViewport/IridescenceBall.visible = true
|
||||
@ -450,6 +422,22 @@ func respawn() -> void:
|
||||
# Is tied to the death animation
|
||||
get_tree().reload_current_scene()
|
||||
|
||||
# When the Enemy stomp AREA enters the enemy collision area -> stomp
|
||||
func _on_BlobbySkin_area_entered(area: Area2D) -> void:
|
||||
if area.is_in_group("harmful") && !levelState.is_dead:
|
||||
die()
|
||||
if area.is_in_group("pit"):
|
||||
shielded = false
|
||||
die()
|
||||
|
||||
# When the Enemy collision BODY enters the enemy collision area -> die
|
||||
func _on_BlobbySkin_body_entered(body: Node) -> void:
|
||||
if body.is_in_group("harmful") && !levelState.is_dead:
|
||||
die()
|
||||
|
||||
func _on_JumpBufferTimer_timeout() -> void:
|
||||
jump_buffer_filled = false
|
||||
|
||||
# This problem stems from trying to decelerate a walk
|
||||
# that was caused by the moving environment and not by input
|
||||
# It is particularly usefull for moving floor physics
|
||||
@ -465,15 +453,28 @@ func _on_Blobby_got_grounded() -> void:
|
||||
floor_friction = base_floor_friction
|
||||
air_strafe_charges = air_strafe_charges + 1 if max_air_strafe_charges > air_strafe_charges else 0
|
||||
|
||||
|
||||
func _on_BlobbySkin_body_exited(body:Node) -> void:
|
||||
# This is for drop through platforms
|
||||
if body.get_collision_mask_bit(7):
|
||||
set_collision_mask_bit(7, true)
|
||||
|
||||
|
||||
func _on_InvincibilityTimer_timeout() -> void:
|
||||
$BlobbySprite.material = null
|
||||
for area in $BlobbySkin.get_overlapping_areas():
|
||||
if area.is_in_group("harmful"):
|
||||
die()
|
||||
|
||||
func handle_grounded_movement(delta: float, direction: Vector2) -> Vector2:
|
||||
return calculate_grounded_velocity(velocity, delta, direction)
|
||||
|
||||
func handle_jump_movement(delta: float, direction: Vector2) -> Vector2:
|
||||
return calculate_jump_velocity(velocity, delta, direction)
|
||||
|
||||
func handle_duck_movement(delta: float, direction: Vector2) -> Vector2:
|
||||
return calculate_duck_velocity(velocity, delta, direction)
|
||||
|
||||
func handle_fall_movement(delta: float, direction: Vector2) -> Vector2:
|
||||
return calculate_fall_velocity(velocity, delta, direction)
|
||||
|
||||
func handle_wallslide_movement(delta: float, direction: Vector2) -> Vector2:
|
||||
return calculate_wallslide_velocity(velocity, delta, direction)
|
||||
|
||||
@ -21,6 +21,7 @@ var state_time := 0.0
|
||||
func _ready():
|
||||
signalManager.connect("getback_timer_up", parent, "die")
|
||||
signalManager.connect("power_up_collected", parent, "receive_power_up")
|
||||
signalManager.connect("got_stomped", parent, "stomp")
|
||||
anim_player.play("RESET")
|
||||
add_state("idle")
|
||||
add_state("duck")
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extends Actor
|
||||
extends Enemy
|
||||
|
||||
onready var left_src = $SlopeRaycastLeft
|
||||
onready var right_src = $SlopeRaycastRight
|
||||
@ -11,15 +11,6 @@ var snap = Vector2.DOWN * 24
|
||||
func _ready() -> void:
|
||||
velocity.x = -120
|
||||
|
||||
|
||||
# TODO adapt to groups
|
||||
func _on_StompDetector_body_entered(body: Node) -> void:
|
||||
if body.global_position.y > get_node("StompDetector").global_position.y:
|
||||
return
|
||||
$StompDetector.remove_from_group("weakpoint")
|
||||
get_node("EnemyBody").disabled = true
|
||||
die()
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# rotation
|
||||
var movement = max(0,sign(sin(time*15)))
|
||||
@ -34,13 +25,3 @@ func _physics_process(delta: float) -> void:
|
||||
var v = Vector2(velocity.x * movement, 0)
|
||||
time += delta
|
||||
move_and_slide_with_snap(v.rotated(rotation), snap.rotated(rotation), FLOOR_NORMAL, false, 4, PI)
|
||||
|
||||
|
||||
func die() -> void:
|
||||
queue_free()
|
||||
levelState.kills += 1
|
||||
|
||||
func _on_EnemySkin_area_entered(area:Area2D) -> void:
|
||||
if area.is_in_group("harmful"):
|
||||
get_node("EnemyBody").disabled = true
|
||||
die()
|
||||
|
||||
@ -10,7 +10,7 @@ extents = Vector2( 2.72463, 1.17848 )
|
||||
extents = Vector2( 15, 6.12039 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 15.534, 10.0962 )
|
||||
extents = Vector2( 14.563, 9.38461 )
|
||||
|
||||
[node name="Caterpillar" type="KinematicBody2D" groups=["harmful"]]
|
||||
scale = Vector2( 0.8, 0.5 )
|
||||
@ -66,7 +66,7 @@ collision_layer = 2
|
||||
input_pickable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
|
||||
position = Vector2( -4.76837e-07, 0.561345 )
|
||||
position = Vector2( 0, -0.2 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="EnemySkin" type="Area2D" parent="." groups=["player"]]
|
||||
@ -74,6 +74,7 @@ process_priority = -1
|
||||
collision_mask = 126
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
|
||||
position = Vector2( 0, 3.76 )
|
||||
scale = Vector2( 1.03, 1.04 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
|
||||
@ -1,15 +1,8 @@
|
||||
extends Actor
|
||||
extends Enemy
|
||||
|
||||
func _ready() -> void:
|
||||
set_physics_process(false)
|
||||
|
||||
# TODO adapt to groups
|
||||
func _on_StompDetector_body_entered(body: Node) -> void:
|
||||
if body.global_position.y > get_node("StompDetector").global_position.y:
|
||||
return
|
||||
$StompDetector.remove_from_group("weakpoint")
|
||||
get_node("EnemyBody").disabled = true
|
||||
die()
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
velocity.y += _gravity * delta
|
||||
@ -24,12 +17,3 @@ func player_on_floor_direction():
|
||||
if collider.is_in_group("player"):
|
||||
return sign(collider.position.x - self.position.x)
|
||||
return 0
|
||||
|
||||
func die() -> void:
|
||||
queue_free()
|
||||
levelState.kills += 1
|
||||
|
||||
func _on_EnemySkin_area_entered(area:Area2D) -> void:
|
||||
if area.is_in_group("harmful"):
|
||||
get_node("EnemyBody").disabled = true
|
||||
die()
|
||||
|
||||
@ -4,10 +4,10 @@
|
||||
[ext_resource path="res://src/Actors/Enemies/Beings/DartingEnemy.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 2.72463, 1.17848 )
|
||||
extents = Vector2( 2.72463, 1.43961 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 15, 6.12039 )
|
||||
extents = Vector2( 15, 3.0301 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 15.534, 10.0962 )
|
||||
@ -30,21 +30,23 @@ process_parent = true
|
||||
physics_process_parent = true
|
||||
|
||||
[node name="EnemyBody" type="CollisionShape2D" parent="." groups=["harmful"]]
|
||||
position = Vector2( 0, 6.48802 )
|
||||
position = Vector2( 0, 4.61815 )
|
||||
scale = Vector2( 5.68128, 5.29182 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]]
|
||||
visible = false
|
||||
modulate = Color( 0, 0.0392157, 1, 1 )
|
||||
position = Vector2( 0, -6.44095 )
|
||||
collision_layer = 2
|
||||
input_pickable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
|
||||
position = Vector2( -4.76837e-07, 0.561345 )
|
||||
position = Vector2( 0, -2.52895 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="LedgeDetectorRays" type="Node2D" parent="."]
|
||||
visible = false
|
||||
position = Vector2( -14, 12 )
|
||||
|
||||
[node name="RayCast2D" type="RayCast2D" parent="LedgeDetectorRays"]
|
||||
@ -63,10 +65,11 @@ collision_mask = 121
|
||||
|
||||
[node name="EnemySkin" type="Area2D" parent="." groups=["player"]]
|
||||
process_priority = -1
|
||||
visible = false
|
||||
collision_mask = 126
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
|
||||
position = Vector2( 5.96046e-07, 2.5 )
|
||||
position = Vector2( -8.07794e-28, 1.5 )
|
||||
scale = Vector2( 1.03, 1.04 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
|
||||
@ -1,33 +1,22 @@
|
||||
extends Actor
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_physics_process(false)
|
||||
velocity.x = -30
|
||||
|
||||
class_name Enemy
|
||||
|
||||
# TODO adapt to groups
|
||||
# TODO Engine error here(what does it WANT???)
|
||||
func _on_StompDetector_body_entered(body: Node) -> void:
|
||||
if body.global_position.y > get_node("StompDetector").global_position.y:
|
||||
return
|
||||
$StompDetector.remove_from_group("weakpoint")
|
||||
get_node("EnemyBody").disabled = true
|
||||
die()
|
||||
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
velocity.y += _gravity * delta
|
||||
if is_on_wall():
|
||||
velocity.x *= -1.0
|
||||
velocity.y = move_and_slide(velocity, FLOOR_NORMAL).y
|
||||
|
||||
if body.is_in_group("player"):
|
||||
signalManager.emit_signal("got_stomped")
|
||||
remove_from_group("harmful")
|
||||
$StompDetector.remove_from_group("weakpoint")
|
||||
get_node("EnemyBody").disabled = true
|
||||
die()
|
||||
|
||||
func die() -> void:
|
||||
queue_free()
|
||||
levelState.kills += 1
|
||||
|
||||
|
||||
func _on_EnemySkin_area_entered(area:Area2D) -> void:
|
||||
if area.is_in_group("harmful"):
|
||||
get_node("EnemyBody").disabled = true
|
||||
|
||||
@ -1,56 +0,0 @@
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://assets/enemy/enemy.png" type="Texture" id=1]
|
||||
[ext_resource path="res://src/Actors/Enemies/Beings/Enemy.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 2.72463, 1.17848 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 15.4794, 6.68174 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 15.534, 10.0962 )
|
||||
|
||||
[node name="Enemy" type="KinematicBody2D" groups=["harmful"]]
|
||||
collision_layer = 2
|
||||
collision_mask = 9
|
||||
script = ExtResource( 2 )
|
||||
|
||||
[node name="enemy" type="Sprite" parent="."]
|
||||
position = Vector2( 0, -1.90735e-06 )
|
||||
scale = Vector2( 0.286789, 0.276348 )
|
||||
texture = ExtResource( 1 )
|
||||
|
||||
[node name="VisibilityEnabler2D" type="VisibilityEnabler2D" parent="."]
|
||||
position = Vector2( 1362.81, -0.138177 )
|
||||
scale = Vector2( 15.4865, 1.28502 )
|
||||
rect = Rect2( -89, -10, 2, 20 )
|
||||
process_parent = true
|
||||
physics_process_parent = true
|
||||
|
||||
[node name="EnemyBody" type="CollisionShape2D" parent="." groups=["harmful"]]
|
||||
position = Vector2( 0, 6.48802 )
|
||||
scale = Vector2( 5.68128, 5.29182 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]]
|
||||
modulate = Color( 0, 0.0392157, 1, 1 )
|
||||
position = Vector2( 0, -6.44095 )
|
||||
collision_layer = 2
|
||||
input_pickable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="EnemySkin" type="Area2D" parent="." groups=["player"]]
|
||||
process_priority = -1
|
||||
collision_mask = 126
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
|
||||
position = Vector2( 5.96046e-07, 2.5 )
|
||||
scale = Vector2( 1.03, 1.04 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[connection signal="body_entered" from="StompDetector" to="." method="_on_StompDetector_body_entered"]
|
||||
[connection signal="area_entered" from="EnemySkin" to="." method="_on_EnemySkin_area_entered"]
|
||||
@ -1,19 +1,9 @@
|
||||
extends Actor
|
||||
extends Enemy
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
set_physics_process(false)
|
||||
velocity.x = -30
|
||||
|
||||
|
||||
# TODO adapt to groups
|
||||
func _on_StompDetector_body_entered(body: Node) -> void:
|
||||
if body.global_position.y > get_node("StompDetector").global_position.y:
|
||||
return
|
||||
$StompDetector.remove_from_group("weakpoint")
|
||||
get_node("EnemyBody").disabled = true
|
||||
die()
|
||||
|
||||
velocity.x = -40
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
velocity.y += _gravity * delta
|
||||
@ -26,13 +16,3 @@ func is_at_ledge():
|
||||
if !raycast.is_colliding():
|
||||
return true
|
||||
return false
|
||||
|
||||
func die() -> void:
|
||||
queue_free()
|
||||
levelState.kills += 1
|
||||
|
||||
|
||||
func _on_EnemySkin_area_entered(area:Area2D) -> void:
|
||||
if area.is_in_group("harmful"):
|
||||
get_node("EnemyBody").disabled = true
|
||||
die()
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
extends Actor
|
||||
extends Enemy
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@ -7,13 +7,6 @@ func _ready() -> void:
|
||||
|
||||
|
||||
# TODO adapt to groups
|
||||
func _on_StompDetector_body_entered(body: Node) -> void:
|
||||
if body.global_position.y > get_node("StompDetector").global_position.y:
|
||||
return
|
||||
$StompDetector.remove_from_group("weakpoint")
|
||||
get_node("EnemyBody").disabled = true
|
||||
die()
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
velocity.y += _gravity * delta
|
||||
if is_on_wall() or !is_safe_drop():
|
||||
@ -27,12 +20,3 @@ func is_safe_drop():
|
||||
if collider.is_in_group("harmful"):
|
||||
return false
|
||||
return true
|
||||
|
||||
func die() -> void:
|
||||
queue_free()
|
||||
levelState.kills += 1
|
||||
|
||||
func _on_EnemySkin_area_entered(area:Area2D) -> void:
|
||||
if area.is_in_group("harmful"):
|
||||
get_node("EnemyBody").disabled = true
|
||||
die()
|
||||
|
||||
@ -4,13 +4,13 @@
|
||||
[ext_resource path="res://src/Actors/Enemies/Beings/SmortEnemy.gd" type="Script" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 2.72463, 1.17848 )
|
||||
extents = Vector2( 2.64025, 1.38585 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=2]
|
||||
extents = Vector2( 15, 6.12039 )
|
||||
extents = Vector2( 15, 4.5301 )
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=3]
|
||||
extents = Vector2( 15.534, 10.0962 )
|
||||
extents = Vector2( 15.534, 10.8173 )
|
||||
|
||||
[node name="SmortEnemy" type="KinematicBody2D" groups=["harmful"]]
|
||||
collision_layer = 2
|
||||
@ -30,8 +30,8 @@ process_parent = true
|
||||
physics_process_parent = true
|
||||
|
||||
[node name="EnemyBody" type="CollisionShape2D" parent="." groups=["harmful"]]
|
||||
position = Vector2( 0, 6.48802 )
|
||||
scale = Vector2( 5.68128, 5.29182 )
|
||||
position = Vector2( -6.85453e-07, 5.42069 )
|
||||
scale = Vector2( 5.56089, 5.35462 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="StompDetector" type="Area2D" parent="." groups=["weakpoint"]]
|
||||
@ -41,7 +41,7 @@ collision_layer = 2
|
||||
input_pickable = false
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="StompDetector"]
|
||||
position = Vector2( -4.76837e-07, 0.561345 )
|
||||
position = Vector2( 0, -1.08915 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="LedgeDetectorRays" type="Node2D" parent="."]
|
||||
@ -68,7 +68,7 @@ process_priority = -1
|
||||
collision_mask = 126
|
||||
|
||||
[node name="CollisionPolygon2D" type="CollisionShape2D" parent="EnemySkin"]
|
||||
position = Vector2( 5.96046e-07, 2.5 )
|
||||
position = Vector2( 6.77626e-21, 2 )
|
||||
scale = Vector2( 1.03, 1.04 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
|
||||
@ -67,11 +67,12 @@ func bind_to_anchor(anchor_node: Node2D, radius: float ) -> void:
|
||||
|
||||
|
||||
func _on_StompDetector_body_entered(body: Node) -> void:
|
||||
if body.global_position.y > get_node("StompDetector").global_position.y:
|
||||
if body.global_position.y - 1 > get_node("StompDetector").global_position.y:
|
||||
return
|
||||
if body.is_in_group("player"):
|
||||
if body.is_in_group("player") && !is_hurt:
|
||||
remove_from_group("harmful")
|
||||
$StompDetector.remove_from_group("weakpoint")
|
||||
signalManager.emit_signal("got_stomped")
|
||||
is_hurt = true
|
||||
|
||||
|
||||
|
||||
@ -8,6 +8,7 @@ signal frees_updated()
|
||||
signal player_died()
|
||||
signal level_completed()
|
||||
signal power_up_collected(kind)
|
||||
signal got_stomped()
|
||||
|
||||
func _on_Timer_timeout() -> void:
|
||||
emit_signal("getback_timer_up")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user