The MIS-VehicleWeapons framework functions as an extended weapon integration architecture built to bridge character controllers, vehicle mechanics, and mounted ordnance systems. Designed specifically as an add-on module, its core architectural goal is the decoupling of physics-driven vehicle movement from high-frequency combat logic. By utilizing a modular component architecture, the system isolates weapon station operations—such as pitch/yaw tracking, ammo management, projectile instantiation, and visual feedback—from the underlying vehicular driving scripts.
At the architectural core, weapon stations are attached as child hierarchies to vehicle root objects. Rotational constraints are calculated in Local Space, preventing world-space coordinate corruption when vehicles undergo steep pitch, roll, or dynamic terrain orientation changes. Input commands rigid update loops by using delegate-driven events or direct input proxy routing, allowing either driver-controlled or dedicated passenger-gunner seats to assume weapon control without refactoring the core vehicle controller.
The structural layout relies on clear separation of concerns across key scripts:
When deploying mounted weaponry in real-time tactical environments, performance stability is dictated by efficient memory allocation and optimized physics queries. The MIS-VehicleWeapons asset addresses these demands through specific structural design choices:
Physics.RaycastNonAlloc and Physics.SphereCastNonAlloc algorithms, suppressing GC (Garbage Collection) allocations during prolonged automatic fire sequences.In standard runtime environments executing high fire-rate mounted miniguns, memory allocation spikes are commonly caused by repeated Instantiate() and Destroy() calls for projectiles and shell casings. Integrating a generic Object Pooler for all visual tracer prefabs and particle instances stabilizes the frame timeline, eliminating garbage collection latency spikes during high-intensity combat scenes.
Configuring a vehicle hardpoint using the MIS-VehicleWeapons extension requires establishing a clean Transform hierarchy and linking the appropriate controller scripts to weapon mount points.
Ensure your vehicle asset model maintains separated sub-mesh nodes for weapon structures. The standard required structure is:
Vehicle_Root (Contains main vehicle controller and Rigidbody)
Turret_Yaw_Base (Pivot point for horizontal rotation; Y-axis aligned up)
Barrel_Pitch_Mount (Pivot point for vertical elevation; X-axis aligned right)
Muzzle_Exit_Point (Empty GameObject placed at the tip of the barrel pointing along local forward Z-axis)Attach the primary turret controller script to the Turret_Yaw_Base transform, assign the Barrel_Pitch_Mount to the pitch field, and map target crosshair queries to the firing script. Below is an example of implementing custom target alignment logic using local space calculations:
using UnityEngine;
namespace MIS.VehicleWeapons
{
public class VehicleTurretController : MonoBehaviour
{
[Header("Transforms")]
[SerializeField] private Transform turretBase;
[SerializeField] private Transform barrelTransform;
[Header("Aim Settings")]
[SerializeField] private float rotationSpeed = 60f;
[SerializeField] private Vector2 pitchLimits = new Vector2(-10f, 45f);
public void ProcessAimTracking(Vector3 targetWorldPos)
{
if (turretBase == null || barrelTransform == null) return;
// Compute local target for Yaw (Horizontal)
Vector3 localTarget = turretBase.parent.InverseTransformPoint(targetWorldPos);
Vector3 dirToTarget = (localTarget - turretBase.localPosition).normalized;
float targetYaw = Mathf.Atan2(dirToTarget.x, dirToTarget.z) * Mathf.Rad2Deg;
Quaternion desiredYaw = Quaternion.Euler(0f, targetYaw, 0f);
turretBase.localRotation = Quaternion.RotateTowards(
turretBase.localRotation,
desiredYaw,
rotationSpeed * Time.deltaTime
);
// Compute local target for Pitch (Vertical)
Vector3 barrelLocalTarget = barrelTransform.parent.InverseTransformPoint(targetWorldPos);
Vector3 barrelDir = (barrelLocalTarget - barrelTransform.localPosition).normalized;
float targetPitch = -Mathf.Atan2(barrelDir.y, Mathf.Sqrt(barrelDir.x * barrelDir.x + barrelDir.z * barrelDir.z)) * Mathf.Rad2Deg;
targetPitch = Mathf.Clamp(targetPitch, pitchLimits.x, pitchLimits.y);
Quaternion desiredPitch = Quaternion.Euler(targetPitch, 0f, 0f);
barrelTransform.localRotation = Quaternion.RotateTowards(
barrelTransform.localRotation,
desiredPitch,
rotationSpeed * Time.deltaTime
);
}
}
}
| Category | Add-Ons / Extensions |
|---|---|
| Latest Version | v1.2.6 (2 tracked releases) |
| File Size | 22.26 MB |
| Added to Platform | February 6, 2026 |
| Views | 8 views |
| Downloads | 1 downloads |
| Favourites | 0 favourites |
| Official Store | Buy Original License on Unity Asset Store → |
| Issue with Package? | Report Broken Link → |