Full Body Awareness Controller

Stick To Surface

Make bullet holes and other decals stick to moving objects.

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

  1. Open the impact effect prefab, for example Shooter's Hit_Gun.
  2. Select the decal, for example the Decal child.
  3. Add Add Component > Game Creator > Full Body Awareness Controller > Stick To Surface.

Settings

SettingDefaultWhat it does
LayersDefaultLayers of the surfaces it sticks to.
Search Distance0.1How far it looks for a surface, in meters.
Align To SurfaceOnTurns a flat decal so it lies on the surface when it arrives at an angle.
Keep Inside EdgesOnSlides or shrinks a flat decal so it does not hang over the edge of the surface.
Remove If Not AttachedOnRemoves 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.