Bullet Time Camera - Default

In order for bullet time effects to be triggered, there needs to be an object in the scene that listens to these events. The logic of creating bullet time in RSB is that there should be an inactive camera in the scene with a script attached to it that enables the camera when bullet time is triggered. The same script shall be responsible for moving the camera to watch the bullet object. RSB already provides this logic in an extremely intuitive and powerful manner. Let's create a new empty game object, rename it to Bullet Time Camera. Then add the BulletTimeCameraDefault.cs script on it, which can be found under InanEvin>Realistic Sniper and Ballistics>src>BulletTime folder. This will automatically add a camera component to the object as well. Set the depth of the camera component to a large value, such as 10 and set the near plane to 0.01, then disable the camera.

The first settings you see are about collision avoidance. This camera will try to avoid objects getting in the way between the camera object and the bullet object. Set the Collision Detection Mask to Everything for now. Then, also add an Audio Source component to the same game object, and assign to the Audio Source field. Any audio clips played by the effects will be played on this component.

Bullet Time Camera Default tool works on effects and stages. Whenever a bullet time event is triggered, an effect will be selected, either by you from the inspector, or as random. Then, the system will play that effect's stages in order. So first, let's create a new effect by hitting the Add New button in Camera Effects field. Open up the new effect's foldout and rename it to Tutorial Effect. Then select this effect from the Used Effect dropdown.

Now if we play and shoot, nothing will happen, as this new effect does not contain any stage. So let's create a new stage, by hitting the Add New button over the Stages field. Then open the stage foldout, rename it to Beginning.

Each stage has the power to manipulate different properties of camera, which are:

  • General: Determines whether this stage will play an audio and how will the next stage get triggered.

  • Timescale: Determines the timescale of the bullet time when this stage is triggered, whether it will be interpolated or not.

  • Motion: Determines how the camera will be placed, whether it's position will be interpolated or not at this stage.

  • Look At: Determines the look at behavior of the camera at this stage.

  • Z Tilt: Determines the euler Z angle of the camera at this stage.

  • Shake: Determines the camera shake effect at this stage.

So now let's head over to the Motion section and set the start position as 0.5, 0, 0. Then hit play, and we will see this when we fire:

However, you will realize it will get stuck like this. This is because the Timescale of our stage is set to 0. Change the Start Timescale to 0.05 and play & fire again. You will see that the bullet will travel, camera will watch from the side and the main camera will be enabled back after bullet hits the target. This doesn't look good though, so let's customize this stage.

First, let's change the floor material so that we can clearly see that the bullet is moving. Click on the floor plane, then click on the material search on it's Mesh Renderer, select the material called Concrete. Next, go back to our Bullet Time Camera object, and continue editing our stage. Let's set the Start Timescale to 0.005. Then, enable Interpolate Position checkmark in Motion section, set the Start Position to 0.5, 0.15, 0.15 then set the End Position to -0.5, -0.15, 0.05. Then set the Duration to 4, click on the Curve and set a linear curve. This basically offsets the camera from the bullet by Start Position, then interpolates the camera towards the offset defined by End Position using the duration and the curve. So the whole stage should look like this:

If you play and shoot now, you will see that our bullet time camera moves from one side of the bullet to the other.

Now let's focus on creating a stage and switching stages. The idea is that we made a stage for the beginning, with a relatively low timescale. Now we want to have a middle stage, where the bullet travels with a higher timescale and we follow the bullet from behind. However, first we need to define how to trigger the next stage. There are multiple methods to do this, but we will use a fixed duration for this tutorial. Make sure that the Trigger Next Method field is set to Duration in General section, and the Duration value is set to 4.

Next, close the Beginning stage foldout, click on Create New button on Stages field to create a new stage, and rename it to Middle. Set the Start Timescale to 0.09. Check the Continue From Previous checkmark in Motion stage. This will ensure when this stage is triggered, the camera position starts from wherever the camera was at the end of the last stage. Then check the Interpolate Position checkmark, and set the End Position to 0, 0.1, -0.2. Set the interpolation duration to 1, and again, set a linear curve. If you play and shoot now, you will see the camera will travel to the back of the bullet when this stage is triggered.

Now as you will see the bullet travels relatively fast when the second stage is triggered, but it still looks bad while it's about to hit the target. So, head over to the General section in Middle stage, change the Trigger Next method to Bullet Path Percentage and set the Percentage value to 0.96.

This will make the system trigger to the next stage when the bullet has traveled 96% of it's path. Then, close the foldout, create a new stage and name it End. Set the Start Timescale to 0.005, go to the Motion section and make sure Continue From Previous and Interpolate Position are unchecked this time. Set the Start Position to 4, 0.5, -5. Set the Position Type to On Target.

The position values work as offsets from the target. By changing the Position Type to OnTarget, we ask the system to put the camera at the center of the hit target, then offset it by the position amounts.

So the End stage should look like this:

As this will be the final stage, we can omit the Trigger Next Method in this case. Since there will not be a next stage, the system will not try to trigger anything.

If we play and shoot now, this is what we will see:

To summarize the logic, we can list:

  • Bullet time event gets triggered, our BulletTimeCameraDefault.cs picks this event, then looks for an effect to play.

  • We created a new effect called Tutorial Effect and set this to be the Used Effect. Now the bullet time camera will start this effect when an object with BulletTimeTarget.cs is hit.

  • First, the Beginning stage is triggered, travelling from one side of the bullet to the other.

  • After 4 seconds has passed, Middle stage is triggered, switching to the back of the bullet.

  • After the bullet has travelled 96% of it's path, End stage is triggered, watching the bullet by placing itself next to the target.

By leveraging the full features of this tool, it is possible to create extremely powerful bullet time effects. All other sections work the same way, most values are set to the start values at the beginning, and they can be interpolated via a specific duration and an animation curve. Play with other sections, such as Camera Shake or Z Tilt to get an idea of what this tool of capable of.

RSB already provides you with a bullet time camera default prefab that includes 10 different bullet time effects. This prefab can be found under the folder InanEvin>Realistic Sniper and Ballistics>System Prefabs with the name Bullet Time - Camera Default Presets. This prefab is also used in demo scenes. It is suggested to keep a copy of this prefab somewhere safe, so that if you make any changes to it you won't lose the original presets that come with the package.

Last updated