DPT_Projectile is an abstract MonoBehaviour that governs all ammunition lifecycle routines once spawned into world space. It encapsulates collision detection filtering, dynamic damage scaling, frame-throttled impact audio compilation, debris fracture separation, and structural cleanup. Custom projectile archetypes inherit directly from this script and override the OnImpact() routine to append distinct behaviors.
The base script requires a Rigidbody and a minimum of two AudioSource components on the root object layer. The primary audio source handles frame-gated impact sounds; the secondary audio source executes looping aerodynamic properties (e.g., wind displacement whistling).
DPT_ProjectileSurfaceImpact companion component. This represents the high-frequency debris layer or environmental reaction (e.g., splintering wood fibers, shattering rock shards, or loose dirt explosions) mapped exclusively to specific target physics layers.DPT_Projectile handles its own baseline penetration and shattering logic, it natively supports Behavior Overrides triggered by the DPT_ProjectileSurfaceImpact companion component. If the surface script dictates a specific layer should instantly shatter or force a penetration punch-through, it will bypass the projectile's internal impact counters and enforce the structural reaction. This keeps layer-specific physics logic decoupled from the projectile's core mass properties.
| Property | Description |
|---|---|
| Impact Sounds | An array pool of AudioClip assets representing the universal projectile sound (the core kinetic mass weight or baseline "thud"). One is selected at random upon a valid collision. Note: Leave this array empty if you prefer 100% of the impact audio tracking handled contextually by the companion surface script module. |
| Pitch Variance | The randomized frequency shift added or subtracted from the baseline audio player modifier (1.0) during collision execution. Default: ±0.15. |
| Velocity Threshold | The minimum relative collision speed (m/s) required to trip the impact sequence. Low-speed grazes or minor rolling interactions are ignored. Default: 2 m/s. |
| Scale Volume With Velocity | If enabled, the volume of the impact sound scales dynamically based on the impact speed. Lighter impacts will naturally sound quieter. |
| Scale Pitch With Velocity | If enabled, the pitch of the impact sound shifts slightly lower at slower speeds to simulate a weaker physical kinetic interaction. |
| Volume Scaling Reference Speed | The impact speed (m/s) at which the audio reaches 100% of its volume and pitch. Slower impacts will scale downwards proportionally. Default: 15 m/s. |
| Min Pitch Multiplier | Only used if Scale Pitch With Velocity is enabled. This is the minimum pitch multiplier applied at very low impact speeds, which smoothly scales up to 1.0 at the reference speed. Default: 0.8. |
| Min Damage | The minimum damage this projectile will always deal on a valid impact, delivered directly to a DPT_SiegeWeapon or DPT_BreakableProp caught within the collision path — regardless of impact speed. |
| Scale Damage With Velocity | If true, damage scales between Min Damage and Max Damage based on impact speed relative to Damage Scaling Reference Speed. Impacts at or below the reference speed always deal exactly Min Damage — they never fall below it. Impacts above the reference speed scale upward, capped at Max Damage. If false, every valid impact deals a flat Min Damage. |
| Max Damage | The maximum damage this projectile can deal when scaling with velocity. This safely caps the upper limit so unexpected physics glitches or extreme collision speeds do not instantly bypass target health pools. |
| Damage Scaling Reference Speed | The impact speed (m/s) at which damage equals exactly Min Damage. Below this speed, damage is clamped to Min Damage; above it, damage scales up toward Max Damage. Default: 20 m/s. |
| Break On Impact | If enabled, instantly shatters the projectile structure into discrete debris fragments upon impact. If disabled, defaults to terminal despawn settings. |
| Impacts Before Break | The number of valid impacts the projectile survives — punching through and retaining momentum per the Penetration settings below — before it breaks apart on the next one. A value of 0 breaks on the very first impact; a value of 1 survives one impact and breaks on the second; and so on. Only relevant when Break On Impact is enabled. |
| Transfer Velocity To Debris | If true, fractured debris chunks inherit 50% of the parent projectile's lingering linear velocity matrix before scatter impulses are processed. |
| Debris Scatter Force | The outward explosion impulse magnitude applied to child debris rigidbodies at the contact epicenter upon structural fracturing. |
| Projectile Shatter VFX | Particle VFX spawned when the projectile itself shatters (e.g., a puff of stone dust or ice) to mask the transition from an unbroken mesh to scattered debris fragments. |
| Enable Penetration | If true, the projectile actively restores its momentum after a non-breaking impact, allowing it to physically punch through destructible geometry. |
| Velocity Retention | A percentage multiplier (0.0 to 1.0) dictating how much kinetic speed is retained after successfully punching through a target. A value of 1 ignores all structural resistance. |
| Embed On Impact | If true, the projectile will embed itself into the hit object and freeze its physics in place. It utilizes matrix-free tracking to remain stuck to moving targets (like rolling siege towers) without being disrupted by hierarchy changes. |
| Embed Depth | How far forward (in meters) the projectile should sink into the target geometry upon impact to simulate a pierced surface. |
| Min Embed Depth | Minimum penetration depth required to stick. If the dynamically calculated depth falls below this threshold, the projectile will bounce or break instead of embedding. This calculation includes automatic compensation for shallow impact angles. |
| Scale Embed With Velocity | If true, the final embed depth scales dynamically based on the projectile's impact speed relative to the reference speed. |
| Embed Scaling Reference Speed | The impact speed (m/s) at which the projectile embeds to its full, maximum Embed Depth. Slower impacts will sink proportionally less. |
| On Despawn Requested | An exposed C# Action delegate hook. External object pool managers can subscribe to this event to intercept the despawn cycle and prevent the object from being destroyed by the engine. |
| Should Despawn | If enabled, triggers the terminal cleanup cycle once the flight or impact sequence concludes. By default, this calls Destroy(), but advanced developers can override the Despawn() method to intercept this call and return the projectile to a custom Object Pool instead. |
| Despawn Delay | The tracking timeframe buffer (in seconds) to wait after an impact before completely deleting the object tree from memory, allowing audio trailing or VFX particle systems to complete natively. |
| Enable Inaccuracy | If true, injects both a randomized launch spread angle transformation and a continuous aerodynamic side-drift physics update using Perlin noise loops. |
| Initial Spread Angle | The maximum angular deviation window in degrees applied as a structural roll/yaw rotation offset at the point of initialization. |
| Continuous Drift Force | The lateral acceleration force scalar applied continuously to push the projectile off-course, simulating micro-shifting crosswinds. |
| Drift Fluctuation Speed | The frequency multiplier governing how rapidly the continuous side-drift alters its directional vector heading through three-dimensional space. |
| Enable Aerodynamic Drag | If true, applies a mass-aware deceleration force to the projectile throughout its flight. Because this force is applied using ForceMode.Force rather than ForceMode.Acceleration, it is automatically divided by the projectile's Rigidbody mass — heavier ammunition resists this deceleration more than lighter ammunition, mirroring real-world drag behavior. |
| Aerodynamic Drag Coefficient | The drag strength scalar applied per unit of speed-squared. Higher values decelerate the projectile faster for a given mass. Since mass factors into the outcome, lighter ammunition (arrows, javelins) will bleed off speed more readily than heavier ammunition (boulders) using the same coefficient value. |
| Enable Cinematic Hang-Time | If true, applies a continuous upward force to counteract global gravity, allowing for slower, more cinematic launch speeds that still travel far without modifying the engine's global physics matrix. |
| Upward Hang Time Force | The amount of upward acceleration to apply. Unity's default gravity is -9.81. Setting this to 4.9 will effectively cut the projectile's gravity in half, resulting in a massive, floaty arc. |
| Unbroken Ammo Object | The child GameObject containing the intact flying model container and its main physics colliders. Hidden immediately upon collision. |
| Embedded Debris Root | A pre-fractured child container asset model configured with loose individual rigidbodies. Activated, unparented, and thrown into root world space on impact. Should be deactivated by default in the prefab. |
| Randomize Initial Rotation | If true, applies a random rotation to the visual mesh on spawn so the projectile doesn't look identical every time. This only rotates the mesh locally, keeping the physics collision orientation and projectile trajectory stable. |
| Enable Flight Spin | If true, forces continuous tracking rotation along a specified axis vector while traveling through the air. |
| Local Spin Axis | The local forward, right, or up vector around which continuous spin transformations are applied (e.g., 0,0,1 for bolt rifling stability). |
| Randomize Spin Axis Signs | If enabled, randomly flips the positive or negative signs of each axis component on launch (e.g., an axis configuration of 1,1,1 can organically convert to -1,1,-1), introducing variations in rotational directions. |
| Spin Speed | The constant tracking rotation velocity calculated in degrees per second. |
| Spin Visuals Only | If true, rotates only the visual child mesh container (Unbroken Ammo Object), ensuring root rigidbodies and main physics colliders stay perfectly stable during physics ticks. |
| Impact Audio Source | Assign an AudioSource configured for impacts. If left empty, one will be created automatically. |
| Travel Audio Source | Assign an AudioSource configured for traveling (whistle/roll). If left empty, one will be created automatically. |
| Travel Audio Clip | The audio clip played while the projectile is moving (e.g., flight wind or ground rolling). |
| Loop Travel Audio | If true, the travel audio will loop continuously. |
| Blend Loop Seam | If true and looping is enabled, crossfades the loop seam using a secondary audio source to seamlessly prevent audio clicks or pops. |
| Loop Blend Duration | Duration in seconds of the crossfade blend. |
| Min Audio Speed | Minimum speed (m/s) required for travel audio to be audible. Audio fades out if slower than this. |
| Travel Fade Speed | How quickly the travel audio fades out to zero volume after an impact or when coming to a rest. |
| Local Cooldown | Per-projectile minimum time buffer (in seconds) enforced between impact registrations to protect against false double-collision events. Default: 0.3s. |
To implement alternative ammunition varieties, author a child script that inherits directly from DPT_Projectile and override the OnImpact(Collision collision, float speed) routine. The underlying engine automatically handles structural damage, frame-gated sound mixers, and debris fracturing before executing your custom override logic.
using UnityEngine;
using DPT.SiegeWeapons;
public class MortarShellProjectile : DPT_Projectile
{
protected override void OnImpact(Collision collision, float speed)
{
// Custom area-of-effect calculations, ground deformation, or unique damage interactions
// Core audio, structural damage, and debris logic are pre-processed by the base script
}
}
Launcher property, configured automatically on spawn. You can invoke Launcher.ImpactEffect(contactPoint) inside your custom overrides to trigger the parent weapon's specialized impact audio behaviors at the hit coordinate.
DPT_Projectile framework is strictly Pool-Ready and designed for zero runtime allocation.
Awake(), the projectile permanently caches all internal Rigidbody and Collider arrays. When a projectile shatters, it safely unparents its debris rigidbodies to prevent them from inheriting the tumbling momentum of moving targets.
OnDespawnRequested Action delegate. The projectile will hand itself over to your script instead of calling Destroy(). When you are ready to fire it again, call ResetForPooling() to instantly vacuum up its broken debris fragments, freeze their physics, and re-enable the root colliders, making the ammunition pristine without triggering Garbage Collection spikes.
DPT_Cannonball is a specialized extension designed for heavy, high-velocity projectile assets. It tracks high-speed ballistic pathways, dynamically scaling its travel whistle pitch relative to its physical speed magnitude to give players a subconscious acoustic cue of its kinetic energy. This looping wind shear volume seamlessly moves towards an audible zero upon hitting geometry to cleanly blend into the base impact framework.
| Property | Description |
|---|---|
| Min Flight Whistle Pitch | Whistle loop pitch at zero or low speed. Default: 0.8. |
| Max Flight Whistle Pitch | Whistle loop pitch once the cannonball reaches the reference speed. Default: 1.4. |
| Whistle Reference Speed | Impact speed (m/s) at which the whistle reaches the Max Flight Whistle Pitch. Speeds above this are clamped to the max. Default: 40 m/s. |
DPT_Boulder alters conventional projectile lifecycle mechanics by transitioning seamlessly from a free-flying air tracking object into a grounded physics asset. Rather than relying on heavy OnCollisionStay loops, it utilizes a highly performant collision contact-counter to track its grounded state. This prevents micro-bouncing audio artifacts and dynamically shifts audio priorities from flying wind whistles into heavy ground friction rumbling loops that match the boulder's active velocity magnitude.
| Property | Description |
|---|---|
| Roll Volume Smoothing | The interpolation factor governing how smoothly the rolling sound loop adjusts to sudden changes in velocity or unexpected terrain drop-offs. Default: 3. |
| Max Roll Speed | The velocity threshold (m/s) at which the ground rolling audio loop reaches its maximum pitch shift and volume scaling boundaries. Default: 15 m/s. |
| Launch Angular Velocity | Applies real physical torque on spawn so the boulder hits the ground already spinning. |
| Settled Threshold | The physics velocity floor below which the boulder is considered fully stationary post-impact, terminating its rolling phase. Default: 0.2 m/s. |
| On Settled | A UnityEvent triggered the exact frame the rolling boulder falls below the settled threshold, ideal for spawning permanent environment craters or shifting navigation meshes. |
| Rolling VFX Prefab | The dust particle system prefab to instantiate when the boulder spawns. |
| Emission Rate Over Distance | The number of particles to emit per unit of distance moved. Default: 5. |
| VFX Scale | Uniform scale multiplier applied to the instantiated rolling VFX. |
Awake(). It explicitly forces its internal shouldDespawn state to false on initialization, ensuring the lifespan cleanup counters do not begin processing until the rock completely finishes its rolling phase and comes to a full stop.0.8f and 1.2f based on its current kinetic velocity tracking data.DPT_BallistaBolt delivers specialized features for heavy piercing ammunition assets. It continuously slerps its physical rigidbody alignment to look directly into its velocity vector during flight, processes advanced multi-axis aerodynamic cosmetic vibrations, handles penetration pinning depth, and includes a structural snap mechanic that separates the tail fletching from the embedded tip on structural clipping.
DPT_BallistaBolt no longer forces the inherited Embed On Impact and Break On Impact fields at runtime. Whatever you configure on the prefab's Inspector is respected as-is, so the same script can be repurposed for non-embedding ammunition (foam darts, blunt bolts, practice rounds) simply by unchecking Embed On Impact — no code changes required.| Property | Description |
|---|---|
| Alignment Speed | The interpolation speed multiplier at which the physical rigidbody slerps its forward look matrix to align with its directional velocity path. |
| Enable Wobble | Toggles a complex, dynamic vibrational multi-axis shake on the perpendicular axes of the bolt during travel. |
| Restrict Wobble To X Axis | If true, restricts the wobble to only the X-axis (up/down pitch) instead of a complex multi-axis flutter. |
| Wobble Frequency | How rapidly the bolt mesh framework vibrates back and forth during advanced wobble processing. |
| Wobble Amplitude | The maximum angular deviation in degrees for the vibration window. |
| Decay Wobble | If enabled, the vibration automatically stabilizes and dampens out smoothly over the duration of its flight path. |
| Wobble Decay Speed | The multiplier rate at which the advanced flight wobble window decreases over time. |
| Impact Force Multiplier | A scaling factor applied against the bolt's mass and velocity matrices when delivering a direct kinetic impulse force to hit rigidbodies. |
| Broken Root | The child GameObject container representing the tip and front shaft model parts that remain permanently pinned into targets when a snap occurs. |
| Snapped Visual | The child GameObject container representing the fletching and tail segment that breaks free and tumbles into world space when a snap occurs. Given an independent physics body on break. |
| Snap Trigger Collider | A dedicated trigger collider tracking the fletching asset area, enabled post-impact to detect moving actors or clearing elements that should clip the tail off. |
| Snap Break Force | The outward physics impulse force applied to kick the snapped tail visual away from its embedded pinning coordinates. |
transform.SetParent workflows on impact. By recording its exact relative position and rotation offsets using inverse transform mapping, it completely immunizes the bolt mesh from non-uniform scaling, stretching, or skewing distortions present on target structures.brokenParents arrays, finds the closest active debris piece, and updates its tracking anchors to tumble realistically with the wreckage rather than just falling out.To preserve maximum performance optimization and maintain a highly scannable workflow, modular behaviors like environment visual matching and camera shaking are separated into independent, optional satellite scripts. To implement these behaviors, drop these components onto any projectile prefab alongside the main baseline DPT_Projectile component tree.
Triggers a decoupled, system-wide broadcast of camera shockwave metrics upon a valid ammunition impact. Instead of scanning scene physics matrices using high-overhead loop parameters or heavy overlap sphere allocation checks, it handles registration through a modern, high-performance static C# event handler model.
| Property | Description |
|---|---|
| Shake Magnitude | The peak intensity and baseline movement strength multiplier applied to listening camera rigs at the moment of impact. |
| Shake Duration | The total lifespan runtime window (in seconds) over which the camera shaking displacement operates before returning to rest. |
| Shake Radius | The maximum calculation distance outward from the impact epicenter where a player's viewport can be located to register the physical rumble attenuation. |
DPT_ProjectileScreenShake script onto the root GameObject of your projectile prefab. Because of the [RequireComponent] attribute, it will safely verify or automatically append the base projectile logic.1.2, a duration of 0.5s, and a radius of 25m, whereas a light ballista bolt may drop to 0.3 magnitude and an 8m radius.OnProjectileImpactShake static event to remain completely decoupled. To listen to this data instantly without manual scripting, drop the companion DPT_CameraShakeReceiver utility component directly onto your camera setup (see section below).A zero-configuration, production-ready utility script designed to serve as the native receiver for your ballistic screen shake systems. It automatically tracks the impact broadcast channel, runs fast proximity distance checks, and applies linear spatial dampening to ensure close-range impacts feel appropriately devastating while distant rumbles drop smoothly to zero.
DPT_CameraShakeReceiver script directly onto your active Unity Camera GameObject.transform.localPosition rather than world space coordinates. This guarantees it can be applied safely to cameras nested inside complex player tracking assemblies, third-person spring arms, or cutscene rigs without breaking their structural pathing.0.5 or 1.0 to introduce realistic friction and air resistance.
Scale X: 3, Y: 0.5, Z: 1). Ensure your bolt prefabs utilize matrix-free tracking (using InverseTransformPoint and InverseTransformDirection parameters) to calculate coordinate offsets manually instead of physically parenting via the engine hierarchy tree.
For all technical assistance, bug reports, asset configuration help, and general support, please reach out via email using the Contact Form. This is the primary and most reliable way to get help with any problems you encounter with the packages.
You can also use this form to inquire about custom freelance technical art services. If your project requires external 3D models to be integrated into the DPT ecosystem—including bespoke vertex-data packing, procedural wood grain mapping, GPU wind systems, or game-ready LOD budgeting—get in touch to discuss your specific needs and availability.