# 5. Blood Splatter and Content Settings
Part of [[Decals and Environment Detail]]. Previous: [[4. Runtime Bullet Holes and Scorch Marks]]. Next: [[6. Decals on Quest Tests and Pitfalls]].
> [!warning] Code not compiled in Unity
> Type-checked against 6000.5.8f1 with URP. Not run.
## 5.1 Where blood goes
Real splatter follows physics, and players read that, even subconsciously:
- **Behind the target** along the shot direction: the "exit" spray on the wall behind.
- **Below the target**: drops on the floor.
- **Never on the target** as a projected decal. Character damage is better as a material effect (a damage mask in the character shader), because a projector box on a moving, animating body slides.
```csharp
// Assets/Scripts/Decals/BloodSplatter.cs
using UnityEngine;
/// <summary>
/// On a hit, sprays blood decals: one on the wall behind the target along the shot direction,
/// and one on the floor below. Respects a global "show blood" setting for content options.
/// </summary>
public sealed class BloodSplatter : MonoBehaviour
{
public static bool ShowBlood = true;
[SerializeField] ImpactDecalSpawner spawner;
[SerializeField] LayerMask environmentMask = 1; // Default layer: walls and floors, not characters
[SerializeField] float behindDistance = 3f;
[SerializeField] float floorDistance = 3f;
[SerializeField, Range(0f, 30f)] float spreadDegrees = 12f;
int _bloodKind = -1;
readonly RaycastHit[] _hits = new RaycastHit[1];
void Start() => _bloodKind = spawner != null ? spawner.KindIndex("blood") : -1;
/// <summary>Call from your damage code with where the hit landed and the direction it travelled.</summary>
public void Splat(Vector3 hitPoint, Vector3 shotDirection, float severity = 1f)
{
if (!ShowBlood || _bloodKind < 0)
return;
var dir = Quaternion.AngleAxis(Random.Range(-spreadDegrees, spreadDegrees), Vector3.up) * shotDirection.normalized;
if (Physics.RaycastNonAlloc(hitPoint + dir * 0.05f, dir, _hits, behindDistance, environmentMask, QueryTriggerInteraction.Ignore) > 0)
spawner.Spawn(_bloodKind, _hits[0], Mathf.Lerp(0.6f, 1.2f, severity));
if (Physics.RaycastNonAlloc(hitPoint, Vector3.down, _hits, floorDistance, environmentMask, QueryTriggerInteraction.Ignore) > 0)
spawner.Spawn(_bloodKind, _hits[0], Mathf.Lerp(0.4f, 0.9f, severity));
}
}
```
### Notes
- **Environment mask only.** Both raycasts use `environmentMask`, so blood lands on walls and floors, never on other characters or props you've excluded.
- **Spread** rotates the shot direction a few degrees around world up, so repeated hits don't stack in one spot.
- **Severity** (0…1) scales the size. Pass damage ÷ max health from your damage code.
- Hook it up from your hit handler: `blood.Splat(hit.point, shotDirection, damage / maxHealth)`. In [[Combat Feel and Hit Feedback]], that's the same place the hit-stop and VFX fire.
- Tag your enemy colliders `Flesh` (or change the tag on `HitscanDecalDemo`), so shots on them make blood instead of bullet holes.
## 5.2 A blood toggle
Many players turn blood off, and some platforms and ratings need it off by default. Treat it as a first-class setting:
```csharp
// Assets/Scripts/Decals/BloodSetting.cs
using UnityEngine;
/// <summary>Persists the blood toggle and applies it at boot. Bind ShowBlood to your settings menu toggle.</summary>
public static class BloodSetting
{
const string Key = "settings.showBlood";
public static bool ShowBlood
{
get => PlayerPrefs.GetInt(Key, 1) == 1;
set
{
PlayerPrefs.SetInt(Key, value ? 1 : 0);
PlayerPrefs.Save();
BloodSplatter.ShowBlood = value;
}
}
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
static void Apply() => BloodSplatter.ShowBlood = ShowBlood;
}
```
Put the toggle in the settings menu from [[Menus, Pause and Settings Flow]], and mention it in [[Accessibility]] options. Turning it off should also stop any blood **particles**, not just decals. Gate the particle spawn on the same flag.
## 5.3 Alternatives that keep feedback
Turning blood off shouldn't make hits feel weaker. Swap, don't delete:
| Context | Replace blood decals with |
|---|---|
| Teen or family rating | Dust or impact "scuff" marks (atlas cells 10–11) |
| Stylized or cartoon | Paint splats in the team colour, which also double as a territory mechanic |
| Robots or creatures | Oil, sparks or ichor, using the same spawner kind with different cells |
| Accessibility (low clutter) | No decal, but keep the hit flash and sound |
Because the spawner picks cells by **kind**, you can swap content by changing which cells the `blood` kind uses at boot. No code changes are needed.