Stick To Surface
Shooter places bullet impact effects where the shot hit, but does not attach them to what was hit. They float in the air when a door opens, a box is pushed or a character moves. Stick To Surface finds the surface the effect was placed on and follows it.
Setup
- Open the impact effect prefab, for example Shooter's
Hit_Gun. - Select the decal, for example the
Decalchild. - Add Add Component > Game Creator > Full Body Awareness Controller > Stick To Surface.
Settings
| Setting | Default | What it does |
|---|---|---|
| Layers | Default | Layers of the surfaces it sticks to. |
| Search Distance | 0.1 | How far it looks for a surface, in meters. |
| Align To Surface | On | Turns a flat decal so it lies on the surface when it arrives at an angle. |
| Keep Inside Edges | On | Slides or shrinks a flat decal so it does not hang over the edge of the surface. |
| Remove If Not Attached | On | Removes the decal when it finds no surface, or when its surface is destroyed or disabled. |
How It Works
- It looks for the surface along all six axes of the object, so it works however the decal is rotated in the prefab.
- Rigidbodies are supported. The decal is pinned to where the bullet hit the body, so pushed or moving bodies do not leave it offset.
- Align To Surface fixes decals that stand up, for example when a weapon spawns its impact effect facing the hit direction instead of lying on the ground.
- Keep Inside Edges checks the decal's four corners against the surface. It slides the decal inwards, also near corners, and shrinks it if the surface is too small.
- Static surfaces are only used for the edge check, so walls and floors cost almost nothing.
- It works with pooled effects. Each time a pooled decal is used again, it goes back to its place in the prefab and sticks to its new surface.
- Remove If Not Attached hides a pooled decal instead of destroying it, so the pool can use it again.
For decals on round or uneven shapes, a URP Decal Projector in the prefab wraps around the surface better than a flat quad. Stick To Surface still makes it follow moving objects.