0 votes

I have a Camera2D using which I've implemented crude camera shake. Currently, I simply change the camera's offset periodically using a timer.

func OnTimerTimeout():
    offset.x = rand_range(-shift, shift)
    offset.y = rand_range(-shift, shift)

Using this method, the camera jumps discretely every time the offset changes.

I dislike how jarring this is and want the camera to move smoothly from one position to another.

It should be possible to implement this using a Perlin noise function that takes time and a seed as input and returns continuous noise between (0,1).

I'm not sure how to access such a function in Godot, or how I would use it if I had it.

Any ideas?

in Engine by (1,577 points)

1 Answer

+3 votes
Best answer

Simplex noise is a different kind of smooth noise that might be coming soon to Godot. As for how to transform that into smooth camera shake, I highly recommend this talk by Squirrel Eiserloh at GDC. you might also be interested in an add-on I wrote for my own projects based on that talk.

by (640 points)
selected by

The SimplexNoise pull request was merged and will be in 3.1 :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.