33 lines
1.1 KiB
GDScript
33 lines
1.1 KiB
GDScript
extends Node
|
|
|
|
# ScreenShakeManager - Handles camera shake effects for impact feedback
|
|
|
|
var camera: Camera3D
|
|
var shake_intensity: float = 0.0
|
|
var shake_duration: float = 0.0
|
|
var shake_timer: float = 0.0
|
|
var target_position: Vector3 # Replaces original_position
|
|
|
|
# Shake presets
|
|
const SHAKE_TARGETED: Dictionary = {"intensity": 0.15, "duration": 0.4}
|
|
const SHAKE_GOAL_COMPLETE: Dictionary = {"intensity": 0.1, "duration": 0.3}
|
|
const SHAKE_LIGHT: Dictionary = {"intensity": 0.05, "duration": 0.2}
|
|
|
|
func initialize(p_camera: Camera3D):
|
|
"""Initialize with specific camera instance."""
|
|
camera = p_camera
|
|
if camera:
|
|
target_position = camera.position
|
|
print("[ScreenShakeManager] Initialized with camera: ", camera.name)
|
|
else:
|
|
push_warning("[ScreenShakeManager] Initialized with null camera")
|
|
|
|
func set_target_position(new_pos: Vector3, duration: float = 1.0):
|
|
"""Smoothly transition to a new base camera position."""
|
|
if target_position == new_pos:
|
|
return
|
|
|
|
# Tween the target position
|
|
var tween = create_tween()
|
|
tween.tween_property(self, "target_position", new_pos, duration).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN_OUT)
|