How to make camera shake in 3D?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Pneuma

Im trying to make the camera shake when the player is sprinting (First Person), how can I achieve this?

:bust_in_silhouette: Reply From: A112

The best way to tackle this would be using rotational shake in your camera script like this:

 set_rotation(Vector3(deg2rad(pitch),0,0)"
 set_rotation(Vector3(0,deg2rad(yaw), 0))
 set_rotation(Vector3(0,0,deg2rad(roll))"

where yaw/pitch/roll can be either random values (shaky af), pre-generated noise or plain sin(time) for a gentle sway.

You can also find tons of tips here Math for Game Programmers: Juicing Your Cameras With Math

A112 | 2020-05-07 16:04