speedin-santa/Scripts/StuckSpot.gd
2024-12-20 01:39:49 -05:00

24 lines
755 B
GDScript

class_name StuckSpot extends StaticBody3D
signal clicked()
@export var finalScale: Vector3 = Vector3(0.3, 0.3, 0.3)
@export var growTime: float = 0.3
@export var shrinkTime: float = 0.1
var tween: Tween
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
tween = get_tree().create_tween()
tween.tween_property(self, "scale", finalScale, growTime)
func _on_input_event(_camera: Node, event: InputEvent, _event_position: Vector3, _normal: Vector3, _shape_idx: int) -> void:
if (event.is_action_released("leftclick")):
clicked.emit()
if (tween): tween.kill()
tween = get_tree().create_tween()
tween.tween_property(self, "scale", Vector3(0.01, 0.01, 0.01), shrinkTime)
await tween.finished
queue_free()