AERIAL WEAPONS • BALLISTICS
HOW TO CREATE A BOMB DROP SYSTEM IN UNITY
Release free-falling munitions that inherit jet aircraft momentum, tilt naturally along their aerodynamic trajectory, and detonate upon ground contact.
Momentum Inheritance Principle
When releasing a bomb from an aircraft, immediately assign the bomb Rigidbody's velocity to match the jet: bombRb.linearVelocity = jetRb.linearVelocity. In FixedUpdate(), rotate the bomb towards its velocity vector using Quaternion.LookRotation(bombRb.linearVelocity) so it falls nose-first.
1
Ballistic Gravity Bomb C# Script
AerialBomb.cs (C#)
using UnityEngine;
[RequireComponent(typeof(Rigidbody))]
public class AerialBomb : MonoBehaviour
{
[Header("Explosion Properties")]
[SerializeField] private float blastRadius = 12f;
[SerializeField] private float explosionDamage = 250f;
[SerializeField] private GameObject explosionEffectPrefab;
[SerializeField] private LayerMask damageLayers;
[Header("Aerodynamics")]
[SerializeField] private float aerodynamicAlignSpeed = 3f;
private Rigidbody rb;
private bool hasExploded = false;
private void Awake()
{
rb = GetComponent<Rigidbody>();
rb.useGravity = true;
}
public void Drop(Vector3 aircraftVelocity)
{
// Inherit carrier speed plus subtle downward push
rb.linearVelocity = aircraftVelocity + (Vector3.down * 2f);
}
private void FixedUpdate()
{
// Align bomb nose with current falling trajectory
if (rb.linearVelocity.sqrMagnitude > 4f)
{
Quaternion targetRotation = Quaternion.LookRotation(rb.linearVelocity);
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, Time.fixedDeltaTime * aerodynamicAlignSpeed);
}
}
private void OnCollisionEnter(Collision collision)
{
if (hasExploded) return;
Detonate();
}
private void Detonate()
{
hasExploded = true;
if (explosionEffectPrefab != null)
{
Instantiate(explosionEffectPrefab, transform.position, Quaternion.identity);
}
// Apply ground shockwave & damage
Collider[] victims = Physics.OverlapSphere(transform.position, blastRadius, damageLayers);
foreach (Collider vic in victims)
{
float dist = Vector3.Distance(transform.position, vic.transform.position);
float damageFactor = 1f - Mathf.Clamp01(dist / blastRadius);
vic.SendMessage("TakeDamage", explosionDamage * damageFactor, SendMessageOptions.DontRequireReceiver);
// Add physics blast push to nearby dynamic rigidbodies
if (vic.attachedRigidbody != null)
{
vic.attachedRigidbody.AddExplosionForce(1500f, transform.position, blastRadius, 1.5f, ForceMode.Impulse);
}
}
Destroy(gameObject);
}
}