feat: Introduce tekton_walking 3D model, implement a CameraContextManager for dynamic camera positioning, and add a ScreenShakeManager script.
This commit is contained in:
@@ -6,7 +6,7 @@ var camera: Camera3D
|
||||
var shake_intensity: float = 0.0
|
||||
var shake_duration: float = 0.0
|
||||
var shake_timer: float = 0.0
|
||||
var original_position: Vector3
|
||||
var target_position: Vector3 # Replaces original_position
|
||||
|
||||
# Shake presets
|
||||
const SHAKE_TARGETED: Dictionary = {"intensity": 0.15, "duration": 0.4}
|
||||
@@ -17,56 +17,17 @@ func initialize(p_camera: Camera3D):
|
||||
"""Initialize with specific camera instance."""
|
||||
camera = p_camera
|
||||
if camera:
|
||||
original_position = camera.position
|
||||
target_position = camera.position
|
||||
print("[ScreenShakeManager] Initialized with camera: ", camera.name)
|
||||
else:
|
||||
push_warning("[ScreenShakeManager] Initialized with null camera")
|
||||
|
||||
func _process(delta):
|
||||
if shake_timer > 0:
|
||||
shake_timer -= delta
|
||||
if camera:
|
||||
var shake_offset = Vector3(
|
||||
randf_range(-shake_intensity, shake_intensity),
|
||||
randf_range(-shake_intensity, shake_intensity),
|
||||
randf_range(-shake_intensity * 0.5, shake_intensity * 0.5)
|
||||
)
|
||||
camera.position = original_position + shake_offset
|
||||
|
||||
if shake_timer <= 0:
|
||||
_reset_camera()
|
||||
|
||||
func _reset_camera():
|
||||
if camera:
|
||||
camera.position = original_position
|
||||
shake_timer = 0.0
|
||||
shake_intensity = 0.0
|
||||
|
||||
func shake(intensity: float, duration: float):
|
||||
"""Trigger camera shake with given intensity and duration."""
|
||||
if not camera:
|
||||
push_warning("Screen shake requested but no camera assigned!")
|
||||
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
|
||||
|
||||
if camera:
|
||||
# If already shaking, reset camera first to get true original position
|
||||
if shake_timer > 0:
|
||||
camera.position = original_position
|
||||
else:
|
||||
original_position = camera.position
|
||||
|
||||
shake_intensity = intensity
|
||||
shake_duration = duration
|
||||
shake_timer = duration
|
||||
# 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)
|
||||
|
||||
func shake_targeted():
|
||||
"""Called when local player is targeted by opponent's powerup."""
|
||||
shake(SHAKE_TARGETED.intensity, SHAKE_TARGETED.duration)
|
||||
|
||||
func shake_goal_complete():
|
||||
"""Called when local player completes a goal."""
|
||||
shake(SHAKE_GOAL_COMPLETE.intensity, SHAKE_GOAL_COMPLETE.duration)
|
||||
|
||||
func shake_light():
|
||||
"""Light shake for minor events."""
|
||||
shake(SHAKE_LIGHT.intensity, SHAKE_LIGHT.duration)
|
||||
|
||||
Reference in New Issue
Block a user