2022-06-17 09:09:23 +02:00
|
|
|
extends Camera
|
|
|
|
|
|
|
|
|
|
|
|
# Depression
|
|
|
|
var downForceStrength = 0
|
|
|
|
|
|
|
|
#Mania
|
|
|
|
export var max_offset = 0.3 # Maximum hor/ver shake in pixels.
|
|
|
|
export var max_roll = 0.1 # Maximum rotation in radians (use sparingly).
|
|
|
|
|
|
|
|
var trauma = 0.0 # Current shake strength.
|
|
|
|
var trauma_power = 2 # Trauma exponent. Use [2, 3].
|
|
|
|
|
|
|
|
var downForce = false;
|
|
|
|
|
|
|
|
onready var noise = OpenSimplexNoise.new()
|
|
|
|
var noise_y = 0
|
|
|
|
|
|
|
|
var pivot
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
func _ready():
|
|
|
|
randomize()
|
|
|
|
noise.seed = randi()
|
|
|
|
noise.period = 4
|
|
|
|
noise.octaves = 2
|
|
|
|
pivot = get_parent();
|
|
|
|
|
|
|
|
|
|
|
|
func changeShaking(setTrauma):
|
|
|
|
trauma = setTrauma
|
|
|
|
|
|
|
|
func changeDownForce(force):
|
|
|
|
downForceStrength = force
|
|
|
|
|
|
|
|
|
2022-06-20 10:33:39 +02:00
|
|
|
func _process(_delta):
|
2022-06-17 09:09:23 +02:00
|
|
|
if trauma:
|
|
|
|
shake()
|
|
|
|
|
|
|
|
if downForceStrength<0:
|
|
|
|
if(pivot.rotation.x > -1.4):
|
|
|
|
pivot.rotate_x(downForceStrength)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func shake():
|
|
|
|
var amount = pow(trauma, trauma_power)
|
|
|
|
noise_y += 1
|
|
|
|
# Using noise
|
|
|
|
v_offset = max_offset * amount * noise.get_noise_2d(noise.seed*3, noise_y)
|
|
|
|
h_offset = max_offset * amount * noise.get_noise_2d(noise.seed*2, noise_y)
|
|
|
|
|
|
|
|
func reset():
|
|
|
|
trauma = 0
|
|
|
|
downForce=false
|
|
|
|
downForceStrength = 0;
|