Learn about this Experimental feature, but you cannot publish a project that uses it.
Camera Transitions
A player's camera_director_component picks the highest-priority registered camera every frame. When that choice changes, instead of cutting right to the new camera, the director runs a transition which describes how the outgoing view becomes the incoming view.
A transition is an object with two parts:
A blend, which is the shape of the interpolation. A linear blend moves at a constant rate, a smootherstep blend eases in and out, a pop blend does not interpolate at all.
A duration, in seconds, which is how long the blend takes. The default is
0.2.
# A three quarter second ease in and out.
MyTransition := camera_transition:
Blend := camera_mode_blend_smootherstep{}
Duration := 0.75Cameras decide their own transitions, rather than the director imposing one. You control this by overriding two failable functions on your camera component:
GetEnterTransition(SourceCamera)returns the transition to use when this camera becomes active, depending on the camera it's taking over. By default, this is a 0.2 second linear blend.GetExitTransition(DestinationCamera)returns the transition to use when this camera stops being active, based on the camera that's taking over. The default implementation of this function fails and returns nothing, so the incoming camera's enter transition is used instead.
When overriding these functions, you can choose if a camera returns a transition or not.
Transition Resolution
When the active camera changes, the director resolves exactly one transition for the change, in this order:
The director calls
GetExitTransitionon the outgoing camera first. If the outgoing camera returns a transition, the director uses it.If
GetExitTransitiondoesn't return a transition, the director falls back toGetEnterTransitionon the incoming camera.If there's no previous active camera to check — such as when the first camera registers to a director — the transition pops instantly, with a duration of 0.0.
Transitions are resolved once, at the moment the set of registered cameras changes, and they are resolved on the server. Both AddCamera and cancelling a camera's registration trigger the resolution, so removing the top-priority camera also picks a transition for whatever becomes active in its place.
Choosing Which Function to Override
Overriding GetExitTransition on a camera means that transition is used whenever the camera is transitioning away, regardless of what the incoming camera specifies. Most cameras don't need that control — the incoming camera's enter transition is usually what should decide, which is why GetExitTransition returns nothing by default.
One situation where you may want to explicitly override GetExitTransition is for aiming down sights in a shooter game. When transitioning from the hip-fire camera to the aim-down-sights camera, you may want explicit control over the length of that transition, but we don’t want that to affect transitions to a completely different camera mode (like a top down camera).
Use it for cameras that must always be exited a particular way, such as a cinematic camera that should hard cut back to gameplay. For other cases, override GetEnterTransition instead when the incoming camera should decide, which is the more common case.
Overriding Transitions in Verse
Override the two functions on your own camera component subclass.
using { /Verse.org/SceneGraph }
using { /Verse.org/Simulation }
# A camera for scripted moments. It eases in over three quarters of a second,
# and always hard cuts when control returns to gameplay.
cinematic_camera_component := class(perspective_camera_component):
GetEnterTransition<override>(SourceCamera : camera_component)<decides><transacts> : camera_transition =
camera_transition:
Blend := camera_mode_blend_smootherstep{}
Because both functions receive the other camera, you can vary the transition by what you are coming from or going to.
# Cut instantly between two cinematic cameras, but ease in from gameplay.
GetEnterTransition<override>(SourceCamera : camera_component)<decides><transacts> : camera_transition =
if (cinematic_camera_component[SourceCamera]):
camera_transition:
Blend := camera_mode_blend_pop{}
Duration := 0.0
else:
camera_transition:
Blend := camera_mode_blend_smootherstep{}
Duration := 0.75Registering the camera is unchanged. The transition is chosen automatically when the priority ordering makes your camera active.
if:
CameraDirector := Player.GetComponent[camera_director_component]
Camera := Entity.GetComponent[cinematic_camera_component]
then:
# Becoming active runs this camera's enter transition, unless the
# outgoing camera provides an exit transition of its own.
set CameraHandle = option { CameraDirector.AddCamera[Camera, Priority := 10000] }
# Cancelling the registration blends to whatever camera is next in priority.
if (Handle := CameraHandle?):
Blends
The blend controls the shape of the interpolation. Duration is expressed by the transition, not by the blend, so the same blend can be reused at different lengths.
| Blend | Behavior |
|---|---|
| Snaps to the target camera immediately. Duration is ignored. |
| Interpolates at a constant rate. This is the default blend on a new |
| Eases in and out using a smoothstep curve. See https://en.wikipedia.org/wiki/Smoothstep. |
| Eases in and out using a smootherstep curve, which is gentler at both ends than smoothstep. See https://en.wikipedia.org/wiki/Smoothstep#Variations. |
| Blends along an arc around the cameras' shared target instead of through a straight line. Its |
Pick camera_mode_blend_orbit when both cameras are looking at the same subject and a straight-line interpolation would swing the view through the world or through the subject. The arc keeps the subject framed for the whole blend. It relies on the camera's target distance, which the camera rig establishes with a ray cast, so it works best with cameras that have a clear focus point.