Skip to content
CRUSHFORMV1.1.0
GET IT ON FAB

VEHICLEENGINE SOUND

Engine sound

The engine sound plays the engine of a vehicle. It crossfades a set of loops, each recorded at one engine speed, and pitches them to the engine’s speed in the game. Under load the engine is louder than when it coasts. The Crushform Engine Audio component plays the sound. The Vehicle adapter and the Chaos adapter create one for the vehicle, as CF_EngineAudio.

Loops. A UCFEngineSoundProfile holds the loops, as layers. A layer is one looping sound, the engine speed it was recorded at, and its volume. The component sorts the layers by speed. It fades between the two loops around the engine’s speed, and pitches each loop to the speed in the game. The pitch stays between Min Pitch and Max Pitch. The audio device limits pitch to 0.4 to 2.0 by default, so these two values work inside that range.

Load. With no throttle the engine plays at Coast Volume. With full throttle it plays at full volume. The volume moves between the two as the load changes.

Run state. The component asks the vehicle’s engine host once a frame for its state: off, cranking or running. While the engine cranks, the Starter Sound loops and the engine loops stay silent. When the engine runs, the loops rise over Start Fade Seconds. When it stops, they fade over Stop Fade Seconds, and the Shutdown Sound plays once.

Earshot. The engine plays only while a listener is within the range of the profile’s Attenuation. Out of earshot the sounds stop. When a listener comes back, the engine is heard as it is at that moment, without a rise or a shutdown it missed.

Cabin. A listener inside the cabin hears the engine quieter and duller. The adapter’s SetCabinMuffled muffles the engine too. A component on its own calls SetCabinMuffling.

Presentation only. The engine sound is silent on a dedicated server, because nothing there hears it. Without an Attenuation on the profile, the sound stays off, and the log says so.

This example makes an engine sound for your own vehicle. The plugin ships a default profile, DA_CF_DefaultEngineSound, with its loops and an attenuation, so you can skip the profile and use it.

  1. In the Content Browser, click Add, choose Miscellaneous, then Data Asset, and pick CFEngine Sound Profile. Name it MyEngineSound in your project’s folder.
  2. Open the profile. Under Layers, add one entry for each loop. Set Sound to a looping sound, RPM to the engine speed it was recorded at, and Volume to its gain. Use a different RPM for each layer.
Engine Sound
Layers3 Array elements
Index [ 0 ]850.0 rpm
SoundSW_CF_Engine_Ranger_0850
RPM850.0 rpm
Volume0.7
Index [ 1 ]2010.0 rpm
Index [ 2 ]2930.0 rpm
AttenuationSA_CF_Engine
The Layers of DA_CF_DefaultEngineSound, with its first layer open, and the Attenuation below them.
  1. Set Attenuation to a sound attenuation asset. The plugin’s SA_CF_Engine is the sample. Without one the engine stays silent.
  2. Optionally set Starter Sound (it must loop, and plays while the engine cranks) and Shutdown Sound (it must not loop, and plays once when the engine stops).
  3. Open Edit, then Project Settings, then Plugins, then Crushform Engine. Check that Engine Sound is on, and that Default Profile is the profile you want for vehicles that name none.
Engine Sound
Engine Sound
Default ProfileDA_CF_DefaultEngineSound
The Engine Sound group in Project Settings, under Plugins > Crushform Engine.
  1. On the vehicle’s adapter, set Engine Sound Profile to MyEngineSound, or leave it empty for the default. Set Engine Sound Offset to move the sound to the engine’s position. Turn on Engine Sound.

Saving the profile runs its checks. They report a profile with no layer, a layer with no sound or a sound that does not loop, two layers with the same speed, no attenuation, a minimum pitch above the maximum, and a shutdown sound that loops.

On a Blueprint, the usual task is to muffle the engine when the listener sits in the cabin. The graph gets the engine audio component from the adapter with Get Engine Audio on CF_Adapter, then calls Set Cabin Muffling on it with a volume scale of 0.5 and a low-pass cutoff of 1200 Hz. On a vehicle with the adapter, Set Cabin Muffled on the adapter instead muffles the rolling sound and the engine together, with the settings’ values or, when its override is on, the adapter’s own.

The graph gets the engine audio from the adapter and muffles it in the cabin.

The same call in C++. Find the component on the vehicle, then call its function. The signature is the one in the header. Your module must list the Crushform modules in its Build.cs, as in Installation.

#include "CFEngineAudioComponent.h"
void AMyVehicle::SetListenerInCabin(const bool bInCabin)
{
if (UCFEngineAudioComponent* Audio = FindComponentByClass<UCFEngineAudioComponent>())
{
// The volume scale and the low-pass cutoff in Hz, applied while muffled.
Audio->SetCabinMuffling(bInCabin, 0.5f, 1200.f);
}
}

The engine’s host, the object that answers the engine state, is set in C++ with SetCrushformHost before the component begins play. Its explicit host wins over the registry’s host for the owner.

Profile values are on UCFEngineSoundProfile, settings are on UCFEngineSettings, and the adapter’s are on UCFVehicleAdapterComponent. Defaults are the code’s.

PropertyWhat it doesDefault
UCFEngineSoundProfile::LayersThe loops, in any order. A layer with no sound is left out.empty
FCFEngineSoundLayer::SoundA looping sound of the engine at one steady speed.none
FCFEngineSoundLayer::RPMThe engine speed the loop was recorded at, in rpm. The loop plays at its own pitch at this speed.1000 rpm
FCFEngineSoundLayer::VolumeThe loop’s gain at its full share of the mix.1.0
UCFEngineSoundProfile::AttenuationThe falloff and spatialisation of every sound. Without it the engine sound stays off.empty
UCFEngineSoundProfile::CoastVolumeThe share of full volume heard with no load.0.6
UCFEngineSoundProfile::RPMInterpSpeedHow fast the heard speed follows the engine’s, in 1/s. 0 follows at once.8
UCFEngineSoundProfile::LoadInterpSpeedHow fast the volume follows the load, in 1/s. 0 follows at once.5
UCFEngineSoundProfile::MinPitchThe lowest pitch a loop is slowed to.0.5
UCFEngineSoundProfile::MaxPitchThe highest pitch a loop is sped up to.2.0
UCFEngineSoundProfile::StartFadeSecondsHow long the loops take to rise from silence once the engine runs. 0 is at once.0.4 s
UCFEngineSoundProfile::StopFadeSecondsHow long the loops take to fade out once the engine stops. 0 is at once.1 s
UCFEngineSoundProfile::StarterSoundLoops while the engine cranks. Empty is a silent start.empty
UCFEngineSoundProfile::ShutdownSoundPlays once when a running engine turns off. Empty is none.empty
UCFEngineSettings::bEngineSoundEngine Sound: the master switch. Off, no engine plays one.on
UCFEngineSettings::DefaultProfileThe profile for an engine that names none.DA_CF_DefaultEngineSound
UCFEngineSettings::SoundClassThe sound class of the engine sounds. Empty is Master.empty
UCFEngineSettings::PriorityThe playback priority of the engine sounds. It is above the rolling sound’s, so a quiet tyre gives way to the engine.0.5
UCFEngineSettings::CabinVolumeScaleThe volume of the engine from inside the cabin.0.8
UCFEngineSettings::CabinLowPassFrequencyThe low-pass cutoff of the engine from inside the cabin, in Hz.3000 Hz
UCFVehicleAdapterComponent::bEngineSoundEngine Sound on the adapter. Needs the master switch in Crushform Engine too.on
UCFVehicleAdapterComponent::EngineSoundProfileThe profile of this vehicle. Empty takes UCFEngineSettings::DefaultProfile.empty
UCFVehicleAdapterComponent::EngineSoundOffsetWhere the engine sound plays, relative to the owner’s root, in centimetres.zero
  1. Press Play and rev the vehicle. Then open the console and run stat CrushformEngine. The Engine Audio Tick time appears while the sound updates.
  2. Drive away from the vehicle. The engine fades as you leave the attenuation’s range, and returns as you come back.

The sound itself does not show in a screenshot. Judge it by ear.

The engine is silent, and the log says the profile has no Attenuation

Section titled “The engine is silent, and the log says the profile has no Attenuation”

Cause: The profile’s Attenuation is empty. Without it the engine sound stays off, with a warning.

Fix: Set Attenuation on the profile. The plugin’s SA_CF_Engine is the sample.

There is no engine sound, and no engine audio component on the vehicle

Section titled “There is no engine sound, and no engine audio component on the vehicle”

Cause: Either Engine Sound is off in Crushform Engine, or Engine Sound is off on the adapter. In both cases the adapter makes no engine audio component.

Fix: Turn on both switches, then play again.

The engine is heard only close to the vehicle

Section titled “The engine is heard only close to the vehicle”

Cause: The engine plays only while a listener is within the range of the profile’s Attenuation: its largest distance.

Fix: Raise the attenuation’s range, or check that the listener is where you expect.

Cause: The engine sound is presentation only. It is silent on a dedicated server, because the server has no listener.

Fix: This is expected. Hear the engine on a client.

Cause: SetCrushformHost is refused once the component has begun play, and the log says so.

Fix: Call SetCrushformHost before the component begins play.