Surface Effects

The Surface Effect Scriptable Object is the recipe for a bunch of different effects to be played in response to a certain type of collision.It might trigger when a bullet hits a wall, when a character places a footstep, or when the player falls violently to the ground.

Each Surface Effect contains the object references and logic for a simple one-shot effect. When triggered it can play a random sound from a list, spawn a set of prefabs (according to random probabilities), or select a randomly scaled decal.

It is important to understand that a Surface Effect object is never spawned in the scene. Instead, it is triggered and responds play playing sounds and spawning other prefabs. The Surface Effect object doesn’t exist at the scene level, but at the project level.

Creating a new Surface Effect

A new Surface Effect can be created from the Assets -> Create -> Ultimate Character Controller -> Surface Effect menu option.This menu is also available when you right click within the project view. However, you may find it easier to just duplicate an existing type.

Inspected Fields

Spawned Objects

A list of objects that can be spawned when the Surface Effect is triggered.Each element will be spawned based on a probability value.

Object

Represents the prefab that is attempted to be spawned. This is perfect for particle effects and rubble prefabs!

Probability

A value of 1 means the prefab will always spawn when the Surface Effect is triggered.A value of 0 means that it will never spawn.

Random Spin

A boolean indicating if a random spin should be applied to the spawned object. If enabled a random rotation will be applied relative to the object’s normal direction.

Decals

Lists the decals that can be spawned as a result of the effect.Only one decal will be randomly chosen out of the list.

Prefabs

A list of decal prefabs that can be spawned. All decal prefabs are assumed to have a MeshFilter and MeshRenderer on their main Transform with a class 2-triangle quad(normal aligned with the Z-vector). The overlap detection features of the Decal Manager require this type of decal.

Min & Max Scale

Multiplies the local XY scale by a random value inside this range when a decal is spawned.The local Z scale is not affected.

Allowed Decal Edge Overlap

With zero overlap any decals that overlap the corner of a wall in the slightest bit will be removed. When the overlap is at its max value (0.5) the decals are allowed to overlap corners all of the way to their center. This feature only works if the scene has a Decal Manager component with Placement Tests enabled.

Audio

When the effect triggers one Audio Clip from the list will be chosen and played.

Audio Clips

A list of Audio Clips that can be played by the Audio Manager when the effect is triggered.

Min & Max Volume

The sound will be played as-is if both the min and max volume values are equal to 1. Any other values will cause the volume of the clip to be modified by a random value inside the range.

Min & Max Pitch

The sound will be played as-is if both the min and max pitch values are equal to 1. Any other values will cause the pitch of the clip to be modified by a random value inside the range.

One Clip Per Frame

Enable this boolean to avoid excessive sound volume on impact with effects that trigger many times at once (such as shotgun pellets).

Random Clip Selection

Should a random clip be selected out of the Audio Clip list? If false then the clips will be selected sequentially.

State

When an effect is triggered it can optionally enable the state on the object that was hit.

State Name

The name of the state that should be triggered when the object is hit. This is useful if for example you’d like to make an enemy move in slow motion when being shot by a gun which affects the time scale of objects.

State Disable Timer

The number of seconds until the state name is disabled. A value of -1 will require the state to be manually disabled at a later point in time.