← Back to ThetaVox Products
ThetaVox

Aim Prediction Solver

Documentation

About

A high-precision projectile targeting system that accurately predicts and hits moving targets in Unity. Perfect for tower defense games, turret systems, and AI characters that need to fire projectiles at moving enemies.

This system uses advanced ballistic calculations to determine the exact launch angle and velocity needed to intercept moving targets, whether you're launching missiles, arrows, fireballs, grenades, or any other projectile.

Key Features

Perfect For

Guide

Basic Setup

Add a MissileLauncher component to your turret or AI GameObject. In the Inspector, assign a Launch Point transform (the muzzle) and a Missile Prefab — the prefab must have a Missile component and a Rigidbody. Set Projectile Speed, toggle Use Gravity to match the prefab's Rigidbody "Use Gravity" setting, and tune Prediction Iterations (3–4 is usually optimal for missiles with short travel times).

Firing at a Target

Call TryLaunchAtTarget whenever you want to fire. It reads the launcher's Inspector settings, computes the firing solution, and spawns/launches the missile in one call:

public class Turret : MonoBehaviour
{
    private MissileLauncher missileLauncher;
    public Transform currentTarget;

    void Start()
    {
        missileLauncher = GetComponent<MissileLauncher>();
    }

    void Fire()
    {
        bool success = missileLauncher.TryLaunchAtTarget(currentTarget);
        if (!success)
        {
            // Target out of range, or missile prefab is missing a Missile component
        }
    }
}

Target Detection

The solver auto-detects a target's velocity and height by searching the target transform, then its hierarchy root, then the root's children, in this order: NavMeshAgentCharacterControllerRigidbody (height taken from a Collider if present). If none are found, the target is treated as stationary. Enable Add Half Height if your target's transform origin is at its base rather than its center, so the solver aims at the target's midpoint.