# Weapon Collision Manager

<div align="left"><figure><img src="https://3303637552-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOAGs3il6rJbkejwPOlEP%2Fuploads%2FOXndO6hKeLj0uEuE8Vaf%2FActorComponent_64x.png?alt=media&#x26;token=b00844b2-cbc3-4f89-9f4b-d2c8e193007c" alt=""><figcaption></figcaption></figure></div>

The **Weapon Collision Manager (AC\_CollisionManager)** is a component that dynamically handles collision tracing, hit detection, and damage processing for weapons. Tracing is enabled or disabled at runtime through the [**Weapon Trace Notify**](https://soulslike-framework.isik.vip/animation-notifies/damaging-and-combos/weapon-trace-notify), ensuring collision checks occur only during specific animation frames.

It is added to the **parent Weapon Item** Actor class by default **(B\_Item\_Weapon).**

### **How It Works**

1. **Initialization**:
   * On `BeginPlay`, the component:
     * Reads the **Trace Sockets** for the start and end positions of the weapon trace.
     * Configures **Trace Radius** and **Trace Types**.
     * Sets up the tracing logic but keeps it **paused by default**.
2. **Animation Notify State (ANS\_WeaponTrace)**:
   * **ANS\_WeaponTrace** is used within weapon animations (e.g., attack swings) to toggle tracing:
     * **Enable**: Starts weapon tracing by unpausing the Event Tick.
     * **Disable**: Pauses weapon tracing to stop unnecessary checks.
3. **Collision Tracing (On Event Tick)**:
   * When tracing is enabled:
     * Performs a **Multi-Sphere Trace** using the socket positions and substepping to combat framerate dependency.
     * If a valid target is detected, the **OnActorTraced** event fires, passing hit data for processing.
4. **Damage and Effects**:
   * The `OnActorTraced` logic handles:
     * **Damage Calculation**: Uses weapon stats and modifiers (e.g., scaling, random variance).
     * **Damage Application**: Applies point damage to the hit target.
     * **Visual Feedback**: Spawns effects like blood splatters or sparks at the impact point.
     * **Audio Feedback**: Plays sound effects for weapon hits.
5. **Debugging**:
   * The **Trace Debug Mode** visualizes traces in real-time, helping developers fine-tune trace positions and radii.

### Example Usage

<figure><img src="https://3303637552-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FOAGs3il6rJbkejwPOlEP%2Fuploads%2FHcWn0s2N4et5Tz2MRVdB%2Fimage.png?alt=media&#x26;token=cb9a68f6-9359-4cef-a45a-48f2f6c6d59b" alt=""><figcaption></figcaption></figure>
