class_name DroppedBlock
|
|
extends Node3D
|
|
|
|
|
|
@export var block_tilt: float = 15.0
|
|
#@export var bounce_height: float = 0.25
|
|
#@export var bounce_duration: float = 1.0
|
|
@export var spin_duration: float = 2.0
|
|
@export var block_size_scale: float = 0.25
|
|
|
|
@onready var start_position: Vector3 = self.position
|
|
|
|
|
|
func drop_block(block_id: String) -> void:
|
|
_create_block(block_id)
|
|
_run_animation()
|
|
|
|
func remove_block() -> void:
|
|
queue_free()
|
|
|
|
|
|
func _create_block(block_id: String) -> void:
|
|
var block: Block = World.BLOCK_PREFAB.instantiate()
|
|
block.rotation.z = block_tilt
|
|
block.set_id(block_id)
|
|
block.scale = Vector3(block_size_scale, block_size_scale, block_size_scale)
|
|
add_child(block)
|
|
block.collision_shape.disabled = true
|
|
|
|
func _run_animation() -> void:
|
|
var tween: Tween = create_tween().set_loops()
|
|
tween.tween_property(
|
|
self,
|
|
"rotation_degrees",
|
|
Vector3(0, 360, 0),
|
|
spin_duration
|
|
).from_current()
|