cannot stomp component
This commit is contained in:
2
scripts/components/cannot_stomp_component.gd
Normal file
2
scripts/components/cannot_stomp_component.gd
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
class_name CannotStompComponent
|
||||||
|
extends Node
|
@@ -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
|
||||||
|
Reference in New Issue
Block a user