class_name WobbleFX
extends Node3D

@export_range(0.0, 10.0, 0.1) var wobble_intensity: float = 1.0
@export_range(0.0, 10.0, 0.1) var wobble_speed: float = 2.0
@export var wobble_rotation: bool = true
@export var wobble_position: bool = false

var time: float = 0.0
var initial_rotation: Vector3
var initial_position: Vector3

func _ready() -> void:
	initial_rotation = get_parent().rotation
	initial_position = get_parent().position

func _process(delta: float) -> void:
	time += delta
	
	if wobble_rotation:
		get_parent().rotation = initial_rotation + Vector3(
			sin(time * wobble_speed) * (wobble_intensity * 0.1),
			sin(time * wobble_speed * 1.2) * (wobble_intensity * 0.1),
			0.0  # Keep Z rotation static
		)
	
	if wobble_position:
		var offset = Vector3(
			sin(time * wobble_speed) * wobble_intensity,
			cos(time * wobble_speed * 1.2) * wobble_intensity,
			0.0  # Keep Z position static
		)
		get_parent().position = initial_position + offset 
