18 lines
481 B
GDScript
18 lines
481 B
GDScript
extends Node2D
|
|
|
|
export var can_be_killed_by_sword = true
|
|
export var can_be_squashed = true
|
|
|
|
func _on_Area2D_area_entered(area):
|
|
#Kill player
|
|
if area.is_in_group("player"):
|
|
area.get_parent().die()
|
|
#Die from sword
|
|
if area.is_in_group("sword"):
|
|
if can_be_killed_by_sword:
|
|
queue_free()
|
|
#Die from rock/ get squashed
|
|
if area.is_in_group("squash"):
|
|
var squasher = area.get_parent()
|
|
if squasher.position.y + squasher.bottom.position.y < global_position.y:
|
|
queue_free()
|