Course contentsShow
← Unity Game Development
Lesson 718 of 82810. VFX and Post-ProcessingFree lesson

Designing Screen-Space Hit Markers and Indicators

You will draw procedural hit markers on the screen to provide clear feedback when attacks successfully land on enemy targets.

In this lesson, you will learn how to create responsive, procedural hit markers that provide immediate, screen-space visual feedback when your attacks successfully land on enemies.

The Concept of Procedural Hit Markers

Rather than relying on static 3D world-space sprites, which can become obscured by geometry or distance, screen-space hit markers are drawn directly over the UI layer. This ensures that the player always receives crisp, high-visibility confirmation of a successful hit. By proceduralizing these markers, we can dynamically scale, fade, and rotate them based on hit intensity or weapon type without cluttering our scene with extra GameObjects.

Implementation Strategy

The most efficient way to achieve this is by using a specialized Canvas set to "Screen Space - Overlay" and drawing the markers via a simple OnGUI script or a dedicated UI manager. When a hit is detected via your weapon logic, you trigger an animation sequence that handles the marker's lifespan.

Consider this lightweight logic to trigger a basic hit marker:

public void DisplayHitMarker(Vector2 screenPosition, float intensity) {
    GameObject marker = Instantiate(hitMarkerPrefab, canvasTransform);
    marker.transform.position = screenPosition;
    
    // Animate scale based on hit intensity
    marker.transform.localScale = Vector3.one * intensity;
    
    // Destroy or return to pool after short duration
    Destroy(marker, 0.2f);
}

Enhancing Feedback

To elevate the feel of your combat, apply a small "scale-up" animation on the marker using LeanTween or DOTween (or a simple Lerp in Update). As the marker appears, it should start slightly larger and shrink rapidly, creating a "pop" effect. Pair this with a subtle change in color—perhaps shifting from white to a bright orange—to differentiate between standard hits and critical strikes.

By keeping these indicators detached from the 3D world coordinates once triggered, you decouple your UI responsiveness from the performance of the physics engine. This ensures that even if frame rates fluctuate during intense combat, the hit feedback remains snappy, legible, and satisfying for the player.

Key Takeaway: Screen-space hit markers provide consistent, high-impact feedback by bypassing 3D scene occlusion, allowing for snappier combat visuals that remain clear regardless of distance or environmental density.