### Concept

In Battle of BackYard, there exists a Photo Mode allowing players to adjust camera position, orientation, and parameters such as Depth of Field, Aperture, etc.

Since the game needs to enable players to create cutscenes (mission editor), I’m faced with the task of building the most “blocky” system possible, which will be easy to use and, at the same time, relatively simple to understand and utilize.

So… I started creating blocks. Each of them stores information about the position, camera settings, and if necessary, I can add new elements (which turned out to be needed… but more on that later).

With two blocks and the time between them, all that’s left is to interpolate… and the first cutscene is ready!

### State no. n

It stores information about the position and direction of the camera at the **nth** stage of scene implementation.

### Interpolation in t time

### State no. n+1

It stores information about the position and direction of the camera at the **n+1st** stage of scene implementation.

Of course, there is still quite a long way to go to reach a satisfying level.

**The camera moves only in a straight line between two points.**At the end of the mission, I want to make a “round” camera movement around the map (or mission target) in the style of Worms 4, so I need to introduce movement along a curve.**The speed is also linear.**This creates a very artificial movement and sudden stop. It is necessary to add optional “acceleration” and “deceleration” of the camera.

Why optional? Because if I decide to make a roundabout around the area, it will consist of two semicircles. In the first one, we accelerate from zero to maximum speed, and in the second one, we start with such a speed and decelerate to zero.

### More movement options

I introduced a variable: *Vector3* positionThrough

If the **x** value of **positionThrough** returns NaN (error), the camera moves in a straight line.

Otherwise, a curve is calculated (positionThrough represents the furthest point from the line connecting the starting and ending positions). When calculating the speed, the length of the curve must of course be taken into account, not just the distance between the endpoints.

The result looks as follows:

Slowing down and speeding up is quite simple. If I wanted only a smooth change of angle, I could just use **Quaternion.Slerp**… But I want to smoothly change many parameters.

The float variable **lerpState** determines at which point of interpolation we are. If we are neither speeding up nor slowing down, we can leave it alone.

If we are speeding up:

lerpState = (Mathf.Cos((1f + lerpState / 2f) * Mathf.PI) + 1f);

If we are slowing down:

lerpState = (Mathf.Cos((1.5f + lerpState / 2f) * Mathf.PI));

If we are doing both at once:

lerpState = (Mathf.Cos((1f + lerpState) * Mathf.PI) + 1f) / 2f;

The effect looks like this:

### More to go

The cutscene system still requires the addition of a few parameters. For example, **local movement relative to the vehicle**. However, it’s very easy to add new parameters to the blocks (and interpolating them at this stage is just one additional line of code).