Camera Shake
Last updated
Last updated
The aforementioned camera components do not inherently support camera shake, camera postprocessing and camera lens effects. But we can figure out some ways to achieve them.
You can readily use the UE5 built-in blueprint nodes StartCameraShake, StartCameraShakeFromSource and PlayWorldCameraShake to invoke a specific camera shake as you want. For camera shakes from source, you can also use nodes Start and StartCameraShake where Target is Camera Shake Source Component.
Create a camera shake class. Right click on content browser, select "Blueprint Class", search for "CameraShakeBase" or "LegacyCameraShake" and clike "Select". By doing this, you create a new camera shake class. Open it, and tune the parameters on the Details
panel. You should specify the camera shake duration, blend time, and oscilliation. You can also specify an animation shake under the Anim Shake
group.
Call camera shake. Back to the blueprint you want to use camera shakes, and use node StartCameraShake, StartCameraShakeFromSource or PlayWorldCameraShake where you can pass in the camera shake class you've just created.
If you are using nodes StartCameraShake and StartCameraShakeFromSource, you should pass in the player camera manager.
If you are using PlayWorldCameraShake, you should specify the location where the camera shake is playing, the effect inner radius and outer radius, as well as the falloff between the two circles.
If you want to trigger camera shakes from source, you can also use the Start and StartCameraShake nodes where Target is CameraShakeSourceComponent.
If you want to stop camera shakes at runtime, you can call the StopCameraShake, StopAllCameraShakes and StopAllInstancesOfCameraShake to terminate active camera shakes of certain class types. All these three nodes require a player camera manager object. You can use node GetPlayerCameraManager
to get it. It is particularly noteworthy that if the active camera shake is infinite (the value of duration set as zero or negative) and you toggle off the "Immediately" option, this camera shake will not be stoppped as you may expect. You can set the shake duration as a large value to resolve this issue. (Update: this issue has been fixed at UE 5.2)
If you want to place a source in your level and automatically trigger camera shake during gameplay, you can click "Add"->"All Classes"->"Camera Shake Source Actor". Place it anywhere you want in your level, and set the value of parameter Camera Shake
to the camera shake class you'd like to use. Most of the time you should also toggle on Auto Start
. Refer to the official Camera Shakes documentation to learn about some basics of camera shakes.
ComponentCameraSystem provides a more convenient way to configure your camera shake without first creating a new camera shake class from blueprint, though you can still provide a shake instance as usual. Just set up the EPlayerCameraManager
in your controller and use the blueprint nodes EasyStartCameraShake and EasyStartCameraShakeFromSource under the Utils
category.
You should be very careful of the EasyStartCameraShakeFromSource node in that this node will instantiate a ECameraShakeSourceActor at where the source should be placed. If there already exists one in the world, this one will be leveraged and moved to the new place. For safety consideration, you should not use this node for infinite camera shakes. If this is your intention, you should use the built-in StartCameraShakeFromSource
node where you must specify a camera shake source component so that you can manually decide when this shake instance is stopped.