The Rumble System makes it easy for you to set up camera shakes, controller vibrations and other rumble effects in your game, based on vehicle acceleration, explosions, collisions, weapons firing and anything else you can think of.
To begin adding rumbles to your scene, add a UVC Rumble Manager component anywhere in your scene.
The UVC Rumble Manager reads all the rumble effects happening in the scene and calculates the overall rumble level each frame, providing a single source to get the current rumble level which is a 0-1 value.
This component is a singleton, which means there should only be one in the scene, and it can easily be accessed in any script using the static 'RumbleManager.Instance' reference.
The UVC Rumble Manager has a property in the inspector named 'Listener', which is a transform that represents the position where the rumbles are being felt. Usually the listener is either the camera or the player vehicle.
There are more settings for controlling rumble attenuation, such as the 'Max Listener Distance' value that represents the maximum distance from the Listener at which rumbles can be felt. Additionally, there is an animation curve in the inspector that represents how rumbles 'fade out' as a function of distance from the Listener's position.
When you add the UVC Rumble Manager component to the scene, you can set a Game Agent (usually this would be the player) as the listener in the inspector, and the Rumble Manager will then track the player's vehicle as the Listener, even when they switch vehicles.
To get the current rumble level (0-1) in any script, simply use the following code:
// Get the current rumble level in any script
float currentRumbleLevel = RumbleManager.Instance.CurrentRumbleLevel;
When you add a rumble to your game, you may want to give it a specific duration and control the amount of rumble over that duration.
This can be done using the Add Rumble component, which comes with tons of customization options in the inspector for animating a rumble effect.
If you would like the rumble to play immediately when an object is enabled in the scene (for example an explosion drawn from a pool) the 'Run On Enable' checkbox should be checked, which is set by default on the Add Rumble component.
You can add the Add Rumble component's 'Run' function to any Unity Event to make the rumble play when the event is called.
If you would like to play a rumble on an active object using code, just make sure it has an Add Rumble component, uncheck the 'Run On Enable' checkbox in the inspector, and use the following code:
// Play an animated rumble using an Add Rumble component
Besides animated rumbles, you can add a rumble level for a single frame. This makes it easy to add rumbles that are a function of some dynamic variable in the scene (such as engine throttle).
To add a single frame rumble, use the following code from any script:
// Add a rumble for this frame only.
To add rumbles for spaceship engines, add a Vehicle Engines 3D Rumble component somewhere on your ship, and customize the settings in the inspector. There are options for adding rumbles based on throttle value, acceleration, and boost.
You may want to add camera shakes based on the rumble level. You can do this by adding a Rumble Shaker component to your camera and customizing the settings in the inspector.
There are scripts to add controller rumbles if you are using either Unity's Input System or Rewired.
For Unity's Input System, simply add an Input System Gamepad Rumbles component anywhere in the scene.
For Rewired, simply add a Rewired Vibration Manager component anywhere in scene.