One of the toughest challenges of making a good gameplay camera is handling collisions. While the default spring arm component of Unreal Engine can handle collision tests and probes, it teleports the camera back and forth which is very jarring and abrupt.
A good gameplay camera has to come up with a smart system of dealing with collisions while keeping the movement of the camera continuous and smooth at all times.
Here are examples from AAA video games.
Source - God of War
Smooth Collisions
Source - Assassin’s Creed: Origins
Smooth Collisions
Source - Uncharted: Lost Legacy
Smooth Collisions
Source - Red Dead Redemption 2
Smooth Collisions
Setting up Collision
First of all, your character’s Spring Arm Component needs to have DoCollisionTest disabled!
Next, if you are using UGC Camera Data Assets, then open your data asset and expand the CollisionSettings section, otherwise open the UGC_CameraCollisionModifier_BP class.
Here you can you set enable the smooth collision but setting both bPreventPenetration and bDoPredicitiveAvoidance to true
The UGC Camera Collision Modifier uses Lyra-inspired Penetration Avoidance Feelers. These feelers are basically a number of spherical sweeps from the camera position to the spring arm component’s origin location.
However, each feeler has a rotation offset to try and cover a wide area around the camera and predict collision before the camera actually collides with an object.
While playing in editor, you can open the console (usually with the ` key) and enter TraceTag CameraPen to show the camera penetration avoidance feelers.
Index 0 is the main feeler and always has an AdjustmentRot = (0, 0, 0)
The less space there is between horizontal feelers, the less the camera will clip through objects. Each feeler is slightly rotated (using the AdjusmentRot field) from the main feeler which is index 0.
The default provided penetration feelers should be good enough for all collision situations so you don’t need to change anything.
And of course, if you want an object to trigger the camera collision, it needs to blockthe Camera channel.
Collision Modifier Settings
There are a number of settings you can tweak for the collision modifier.
PenetrationBlendInTime: The time the camera takes to go to the safe location after a collision has been detected.
PenetrationBlendOutTime: The time the camera takes to go back to its normal position after the collision has finished.
bPreventPenetration: If true, does collision checks to keep the camera out of the world.
bDoPredictiveAvoidance: If true, try to detect nearby walls and move the camera in anticipation. Helps prevent popping.
PenetrationAvoidanceFeelers: These are the spherical shaped feeler rays that are used to find where to place the camera.
* Index: 0 : This is the normal feeler we use to prevent collisions. Goes from the camera straight to the spring arm component position.
* Index: 1+ : These feelers are used if you enable bDoPredictiveAvoidance, to scan for potential impacts if the player were to rotate towards that direction and primitively collide the camera so that it pulls in before impacting the occluder.
AdjustmentRot: FRotator describing deviance from main ray which is index 0 ray
(Reminder: X=Roll, Y=Pitch, Z=Yaw).
WorldWeight: How much this feeler affects the final position if it hits the world.
PawnWeight: How much this feeler affects the final position if it hits a APawn (setting to 0 will not attempt to collide with pawns at all).
ProbeRadius: The radius of this feeler probe.
IgnoreCameraCollisionTag: Actors with this tag will ignore camera collisions.
Collision Modifier Functions
You can do this either by calling SetCameraCollisionSettings on the BP_UGCCameraManager
Or you can set them through the UGCCameraDataAssets, and then calling SetCameraData on BP_UGCCameraManager (see