-
Notifications
You must be signed in to change notification settings - Fork 0
Feature ‐ Easy camera shaking ‐ CineCam wiki
Lukas Schmidt edited this page May 28, 2024
·
3 revisions
This guide applies to both 2D and 3D!
CineCam:
VirtualCam:
CineCam makes camera shaking easy!
You can shake a camera by its offset, which allows it to shake even during movement.
You can also shake using zoom (2D) / FOV (3D) or with the camera rotation.
This allows for many effects, with configurable intensity, duration and interpolation.
2D
3D
2D ONLY!
extends CineCam2D
var intensity_vector_offset : Vector2
var intensity_vector_zoom : Vector2
var duration_in_seconds : float = 2.0
var intensity_float : float = 10.0
func _ready():
var x_axis_offset : float = 5.0
var y_axis_offset : float = 2.0
intensity_vector_offset = Vector2(x_axis_offset, y_axis_offset)
var x_axis_zoom : float = 0.15
var y_axis_zoom : float = 0.15
intensity_vector_zoom = Vector2(x_axis_zoom, y_axis_zoom)
func _input(event):
if event.is_action_released("ui_up"):
# Will shake the camera by its offset x and y, which means the camera can shake while moving.
shake_offset(intensity_vector_offset, duration_in_seconds)
if event.is_action_released("ui_down"):
# Will shake the camera by its zoom x and y. VERY INTENSE, KEEP VALUES LOW!
# The camera can shake while moving.
shake_zoom(intensity_vector_zoom, duration_in_seconds)
if event.is_action_released("ui_left"):
# Will shake the camera by its rotation in degrees.
# Camera2D "ignore_rotation" property must be set to false.
# The camera can shake while moving.
shake_rotation(intensity_float, duration_in_seconds)
if event.is_action_released("ui_right"):
# Same as before, but this time with other interpolation.
shake_rotation(intensity_float, duration_in_seconds, Tween.EASE_IN, Tween.TRANS_ELASTIC)
3D ONLY!
extends CineCam3D
var intensity_vector_offset : Vector2
var intensity_vector_rotation : Vector3
var duration_in_seconds : float = 2.0
var intensity_float : float = 10.0
func _ready():
var x_axis_offset : float = 5.0
var y_axis_offset : float = 2.0
intensity_vector_offset = Vector2(x_axis_offset, y_axis_offset)
var x_axis_rotation : float = 2.0
var y_axis_rotation : float = 2.5
var z_axis_rotation : float = 3.5
intensity_vector_rotation = Vector3(x_axis_rotation, y_axis_rotation, z_axis_rotation)
func _input(event):
if event.is_action_released("ui_up"):
# Will shake the camera by its offset h and v, which means the camera can shake while moving.
shake_offset(intensity_vector_offset, duration_in_seconds)
if event.is_action_released("ui_down"):
# Will shake the camera by its fov. VERY INTENSE, KEEP VALUES LOW!
# The camera can shake while moving.
shake_fov(intensity_float, duration_in_seconds)
if event.is_action_released("ui_left"):
# Will shake the camera by its rotation in Vector3 euler angles.
# The camera can shake while moving.
shake_rotation(intensity_vector_rotation, duration_in_seconds)
if event.is_action_released("ui_right"):
# Same as before, but this time with other interpolation.
shake_rotation(intensity_vector_rotation, duration_in_seconds, Tween.EASE_IN, Tween.TRANS_ELASTIC)
My Socials
GitHub | LinkedIn | lnk.bio
Copyright(c) 2014 - present Godot Engine contributors(see AUTHORS.md), Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur.
Godot Repository