Surface Manager
Use Surface Manager to resolve a hit into a Surface Type, then select the Surface Effect paired with the incoming Surface Impact. One footstep or bullet-hit source can produce different feedback on wood, metal, dirt, and other materials.
Set up the manager
- Open Tools > Opsive > Ultimate Character Controller > Setup Manager > Scene and select Add Managers under Manager Setup.
- Select Surface Manager on the created or reused
Gameobject. Keep one active configured manager in the scene. - Set Main Texture Property Name to the shader property containing the registered texture: the component default is
_BaseMap; many Built-in shaders use_MainTex. - Create a Surface Impact, Surface Types, and Surface Effects. On each Surface Type, add an Impact Effects pair for the test impact and assign its response.
- Assign that same Surface Impact to the contact source, such as Character Foot Effects, Jump, Fall, an item action, or a Trajectory Object.
Register textures or identify objects
Under Object Surfaces, add a row, assign its Surface Type, then use Add Texture to register the material’s texture. Register each Texture once. The initial UV rectangle is X 0, Y 0, W 1, H 1.
| Target | Configuration |
|---|---|
| Static object with one material | Register its shared material’s texture using the exact Main Texture Property Name. |
| Multiple materials or a tested UV region | Use a MeshCollider with readable mesh data and register the material textures. |
| Atlas regions, skinned meshes, procedural materials, or critical objects | Use a Surface Identifier with an explicit Surface Type. |
| Terrain ground | Register every Terrain Layer diffuse texture. The dominant alphamap layer at the hit supplies the texture. |
| Terrain trees | Register tree textures and enable Detect Terrain Tree Textures. Trees need usable colliders; measure the extra detection cost. |
A Surface Identifier takes priority over renderer texture detection. Place one intended identifier on the collider GameObject; lookup otherwise searches children and parents. TerrainCollider uses terrain-layer detection instead.
Use Surface Identifier for legacy secondary-texture shaders rather than depending on shader-specific mask conventions. An identifier can leave Surface Type empty and still control Allow Decals while ordinary texture detection supplies the type.
Inspector settings
| Inspector field | Default | Purpose |
|---|---|---|
| Object Surfaces | Empty | Maps Surface Types to unique textures and their UV rectangles. |
| Main Texture Property Name | _BaseMap |
Selects the shader texture property used for renderer lookup. |
| Detect Terrain Tree Textures | Disabled | Tests tree textures separately from terrain ground; CPU-intensive. |
| Fallback Surface Impact | None | Supplies an impact for null input and the final fallback lookup. |
| Fallback Surface Type | None | Supplies an unresolved type or a response when a known type lacks a requested pair. |
| Fallback Allow Decals | Enabled | Controls decal permission when an initially missing impact or type is substituted. |

Resolve responses and fallbacks
Resolution follows this order:
- Substitute Fallback Surface Impact when the incoming impact is null.
- Substitute Fallback Surface Type when detection has no type.
- Stop without an effect when the resolved type is absent or its Impact Effects list is empty; otherwise look for the requested pair.
- If a detected type lacks the pair, try that impact on Fallback Surface Type.
- If no effect resolves, try Fallback Surface Impact on the type currently being used.
- Spawn the selected effect, or return
falsewhen none resolves.
Keep one pair per impact on each type. Give the fallback type a nonempty list containing the intended fallback response. Leave fallbacks unassigned when unknown hits should remain silent.
For a firm per-object decal policy, use Surface Identifier > Allow Decals. For approximate fallback responses, choose a Surface Effect without decals. A null collider also prevents decals. Decal Manager owns placement and decal lifetime; Surface Effects own their particles, audio, and temporary States.
Verify the response
- Register distinct Wood and Metal textures, map them to different Surface Types, and pair both with the same Bullet Hit Surface Impact but different effects.
- Hit both objects with the same source. Wood and Metal should produce their respective feedback.
- Temporarily assign Wood through a Surface Identifier on the metal collider. Restart Play Mode and confirm the explicit type wins, then restore the intended type.
- Test an unmapped target and null impact against the chosen fallback policy. Disable Allow Decals on one identifier and confirm other feedback still plays without its decal.
- For terrain, test inside each painted layer and on a registered tree when tree detection is enabled.
Troubleshooting
| Symptom | Check | Fix |
|---|---|---|
| No response | Source impact and Impact Effects pair | Use the same impact at the source and on the type; assign an effect. |
| Everything uses fallback | Shader property and actual material texture | Correct Main Texture Property Name and register the shared texture. |
| A mesh resolves the wrong type | Collider, readable mesh, triangle index | Use the MeshCollider workflow or an explicit Surface Identifier. |
| A texture is registered repeatedly | Object Surfaces entries | Keep one registration; use identifiers or separate textures for distinct regions. |
| An edit has no effect | Cached collider, material, hierarchy, or mapping | Make the edit outside Play Mode and start a fresh session. |
Developer reference
SurfaceManager.SpawnEffect provides regular and footprint-aware overloads, accepting the hit collider or an explicit Collider. It returns whether an effect resolved. Footprint calls respect SurfaceType.AllowFootprints.
GetSurfaceType, GetSurfaceIdentifier, and GetSurfaceEffect support custom resolution; the last also writes the resolved type and decal permission through reference parameters. Types live in Opsive.UltimateCharacterController.SurfaceSystem.
Configure mappings before Awake. Collider and texture lookups are cached, and Surface Type impact maps initialize on first use. Restart the session after changing mappings, materials, or hierarchy. Scene and asset serialization preserve authored configuration; gameplay saving and network authority belong to the project. See Surface System and Object Pool.