@Megalomaniak
im trying out the trauma function
get noise 2d gives "nan" errors, this is probably cause noise functions have changed in godot4
also the camera isnt resetting to original rotation over time
@onready var noise = FastNoiseLite.new()
var noise_y = 0
var trauma = 0.0 # Current shake strength.
var trauma_power = 2 # Trauma exponent. Use [2, 3].
func _ready():
noise.noise_type = noise.TYPE_SIMPLEX_SMOOTH
noise.frequency = 16.0
randomize()
noise.seed = randi()
func _process(delta):
if trauma:
trauma = max(trauma - decay * delta, 0)
shake()
func add_trauma(amount):
trauma = min(trauma + amount, 1.0)
func shake():
var amount = pow(trauma, trauma_power)
noise_y += 1
$CamRoot.rotate_z(deg2rad(max_roll * amount * noise.get_noise_2d(noise.seed, noise_y))) #"math is_nan'v.x" is true > error
$CamRoot.rotate_x(deg2rad(max_roll * amount * noise.get_noise_1d(noise_y)))
print(noise.get_noise_1d(noise_y))#prints correct values
and i get weird result when looking around.
probably cause im also moving the camera in input
func _input(event):
if event is InputEventMouseMotion:
# Rotates the view vertically
$CamRoot.rotate_x(deg2rad(event.relative.y * MOUSE_SENSITIVITY * -1))
$CamRoot.rotation.x = clamp($CamRoot.rotation.x, deg2rad(-80), deg2rad(80))
# Rotates the view horizontally
self.rotate_y(deg2rad(event.relative.x * MOUSE_SENSITIVITY * -1))