fix stomping
This commit is contained in:
@@ -13,7 +13,7 @@ func _ready() -> void:
|
|||||||
if area2d:
|
if area2d:
|
||||||
area2d.body_entered.connect(_on_area2d_body_entered)
|
area2d.body_entered.connect(_on_area2d_body_entered)
|
||||||
else:
|
else:
|
||||||
print("Collectable node missing Area2D child.")
|
printerr("Collectable node missing Area2D child.")
|
||||||
|
|
||||||
root = get_parent()
|
root = get_parent()
|
||||||
|
|
||||||
|
@@ -15,7 +15,6 @@ func _ready() -> void:
|
|||||||
|
|
||||||
func deal_damage(target: HealthComponent) -> void:
|
func deal_damage(target: HealthComponent) -> void:
|
||||||
target.decrease_health(damage)
|
target.decrease_health(damage)
|
||||||
print("Dealt damage to target!")
|
|
||||||
|
|
||||||
|
|
||||||
func on_area2d_body_entered(body: Node2D) -> void:
|
func on_area2d_body_entered(body: Node2D) -> void:
|
||||||
|
@@ -19,11 +19,11 @@ func _ready() -> void:
|
|||||||
root = get_parent()
|
root = get_parent()
|
||||||
|
|
||||||
if not sprite2d:
|
if not sprite2d:
|
||||||
print("SideToSideMovement node missing Sprite2D child.")
|
printerr("SideToSideMovement node missing Sprite2D child.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if not left_ray or not right_ray:
|
if not left_ray or not right_ray:
|
||||||
print("SideToSideMovement node missing RayCast2D children.")
|
printerr("SideToSideMovement node missing RayCast2D children.")
|
||||||
return
|
return
|
||||||
|
|
||||||
setup_timer()
|
setup_timer()
|
||||||
|
@@ -5,7 +5,6 @@ extends Node
|
|||||||
@export var area2d: Area2D
|
@export var area2d: Area2D
|
||||||
@export var root: Node2D
|
@export var root: Node2D
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
if not area2d:
|
if not area2d:
|
||||||
printerr("No area2d assigned!")
|
printerr("No area2d assigned!")
|
||||||
@@ -31,8 +30,13 @@ func on_area2d_body_entered(body: Node2D) -> void:
|
|||||||
if root.global_position.y < body.global_position.y:
|
if root.global_position.y < body.global_position.y:
|
||||||
if root is PlayerController:
|
if root is PlayerController:
|
||||||
var velocity: Vector2 = root.previous_velocity
|
var velocity: Vector2 = root.previous_velocity
|
||||||
print("Velocity: ", velocity)
|
|
||||||
if velocity.y > 0.0:
|
if velocity.y > 0.0:
|
||||||
deal_damage(health_component)
|
deal_damage(health_component)
|
||||||
print("Dealt damage to ", body)
|
|
||||||
|
var damage_component: DamageComponent = body.get_node_or_null("DamageComponent")
|
||||||
|
if not damage_component:
|
||||||
|
return
|
||||||
|
damage_component.set_process(false)
|
||||||
|
await get_tree().process_frame
|
||||||
|
damage_component.set_process(true)
|
||||||
|
|
Reference in New Issue
Block a user