2024-08-19 01:29:43 +02:00
|
|
|
extends StaticBody2D
|
|
|
|
|
2024-08-19 03:15:07 +02:00
|
|
|
@export var laser_path: NodePath = "../StaticBody2D"
|
2024-08-19 01:29:43 +02:00
|
|
|
@export var required_scale: Vector2 = Vector2(1.0, 1.0)
|
|
|
|
@export var player_required_scale: Vector2 = Vector2(2.0, 2.0)
|
|
|
|
|
|
|
|
@onready var animation = $AnimationPlayer
|
|
|
|
|
|
|
|
var laser: Node2D = null
|
|
|
|
var is_activated = false
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
laser = get_node(laser_path)
|
|
|
|
|
|
|
|
func _on_body_entered(body: Node):
|
|
|
|
print("Wird erkannt")
|
2024-08-19 03:15:07 +02:00
|
|
|
print(body)
|
|
|
|
print(body.scale)
|
|
|
|
if (body is AnimatableBody2D and body.scale >= required_scale) or (body is CharacterBody2D and body.scale >= player_required_scale):
|
2024-08-19 01:29:43 +02:00
|
|
|
animation.play("Disable")
|
|
|
|
activate_plate()
|
|
|
|
|
|
|
|
func _on_body_exited(body: Node):
|
2024-08-19 03:15:07 +02:00
|
|
|
if (body is AnimatableBody2D and body.scale >= required_scale) or (body is CharacterBody2D and body.scale >= player_required_scale):
|
2024-08-19 01:29:43 +02:00
|
|
|
animation.play("Enable")
|
|
|
|
deactivate_plate()
|
|
|
|
|
|
|
|
func activate_plate():
|
|
|
|
print("wird aktiviert")
|
|
|
|
if not is_activated:
|
|
|
|
is_activated = true
|
|
|
|
if laser:
|
2024-08-19 03:15:07 +02:00
|
|
|
laser.queue_free()
|
|
|
|
# TODO: fix error when called again
|
2024-08-19 01:29:43 +02:00
|
|
|
|
|
|
|
func deactivate_plate():
|
|
|
|
if is_activated:
|
|
|
|
is_activated = false
|