cannot stomp component

This commit is contained in:
2025-02-09 07:09:31 +01:00
parent a9b195500a
commit 402b819f05
2 changed files with 13 additions and 6 deletions

View File

@@ -0,0 +1,2 @@
class_name CannotStompComponent
extends Node

View File

@@ -5,6 +5,7 @@ extends Node
@export var area2d: Area2D @export var area2d: Area2D
@export var root: Node2D @export var root: Node2D
func _ready() -> void: func _ready() -> void:
if not area2d: if not area2d:
printerr("No area2d assigned!") printerr("No area2d assigned!")
@@ -27,6 +28,10 @@ func on_area2d_body_entered(body: Node2D) -> void:
printerr("No HealthComponent assigned!") printerr("No HealthComponent assigned!")
return return
var cannot_stomp_component: CannotStompComponent = body.get_node_or_null("CannotStompComponent")
if cannot_stomp_component:
return
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