Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Screen Shake na Godot 4 simples :
- extends Camera2D
- @export var shake_intensity: float = 5.0 # Intensidade do shake
- @export var shake_duration: float = 0.5 # Duração do shake em segundos
- var shake_timer: float = 0.0
- func _input(event: InputEvent) -> void:
- if event.is_action_pressed("ui_sk"):
- start_screen_shake()
- func start_screen_shake() -> void:
- shake_timer = shake_duration
- func _process(delta: float) -> void:
- if shake_timer > 0:
- shake_timer -= delta
- # Aplica o shake à câmera
- offset = Vector2(randi_range(-shake_intensity, shake_intensity), randi_range(-shake_intensity, shake_intensity))
- else:
- offset = Vector2.ZERO # Para o shake quando o timer acabar
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement