Skip to content

CVR Damage Raycaster

Raycast-based damage source that integrates with the Combat System. Requires a Damage component and a ParticleSystem on the same GameObject ([RequireComponent]). For every newly spawned particle, the raycaster fires one hit ray — letting you use any particle system as a bullet emitter, hitscan line, damage cone, or area-of-effect burst.

When enabled, the ray is limited to the distance from emitter to particle. When disabled, the ray extends to infinity. Useful for cone-shaped patterns where you want the ray to stop at the particle’s reach.

Each Update:

  1. Reads the current particle set from the attached particle system and builds a delta of added particles (particles are identified by their randomSeed).
  2. For each new particle this frame, determines the ray origin and direction based on the particle shape type:
    • Sphere / Hemisphere / Circle emitters — ray originates at the emitter transform and travels toward the particle.
    • Other shapes — ray originates at the intersection of the particle’s velocity with the emitter’s forward plane. If no intersection exists, fall back to the emitter.
  3. Casts a ray with the emitter’s collision mask (particleSystem.collision.collidesWith) ignoring triggers.
  4. On hit, dispatches damage via the Combat System (for players) or the matching Object Health component (for world/prop colliders).

The component uses an internal raycastBuffer that accumulates +1 per cast and decays by 20 * deltaTime per frame. Casts are skipped once the buffer reaches 20, protecting against frames with hundreds of simultaneous particle births.

  • CVR-GameFiles/ABI.CCK.Components/CVRDamageRaycaster.cs