Surface System
The Surface System is responsible for spawning effects caused by collisions and impacts. It is designed to be dynamic, powerful, and useful in a board range of possible physics situations.
Features Overview
Surface Effect System
Spawns random sounds, prefabs, and decals upon impact/collision with objects and characters. To increase randomness sounds can have varying pitch, prefabs can have spawn probability, and decals can have a random scale.
Decal Manager
Removes decals if they overlap with wall corners, and ages (weathers) remaining ones. Decals can fade and rotate.
Character Foot Effects
Handles footstep and footprint effects with four footstep detection modes.
Texture Fallbacks
Allows you to identify surfaces depending on terrain or object textures. Supports mapping UV regions within a texture.
Default Fallbacks
Determines the best effect to play in situations where the system doesn’t have information about the impact or surface type.
Logic Overview
A Surface Impact and Surface Type trigger a Surface Effect.
The typical flow for an effect being generated is as follows:
- A collision is caused by an object (such as the character or a projectile) with an assigned Surface Impact.
- A Surface Type is found based off of the collision object.
- A Surface Effect is then retrieved which should be used base off of the Surface Impact – Surface Type combination.
- That Surface Effect finally spawns the particles, decals, objects, or sounds into the scene.
Component Overview
The Ultimate Character Controller scene will have a Surface Manager, Decal Manager, and Object Pool component generated when the Setup Scene button is pressed within the Setup Manager. Surface Impact, Surface Type, and Surface Effect are ScriptableObjects created at design time. Surface Identifier and Character Foot Effects are assigned to an object within the scene.
Surface Manager
Contains fallback Surface Types derived from the textures of a target object. Also contains default fallbacks for (potentially missing) impact and surface effects.
Decal Manager
Handles the fading out (weathering) of decals and smart removal of any badly placed decals.
Object Pool
Handles recycling of objects that are frequently destroyed and reused. Saves lots of memory and is good for performance.
Surface Impact
Identifies the collision type for determining the Surface Effect. Typical Surface Impacts are Bullet Hit, Fall Impact, Footstep, etc. If you’re coming from version 1 of UFPS this object was previously known as vp_ImpactEffect.
Surface Type
Identifies the surface of the object that was hit by the Surface Impact.
Surface Effect
A recipe for a group of effects which should be spawned in response to a certain type of collision.
Surface Identifier
Associates scene colliders with Surface Types. Attaches to any and all scene object which can be static or moving. One per collider.
Character Foot Effects
Attaches to the character and handles the footstep and footprint effects.