Your cart is currently empty!
using UnityEngine;
using System.Collections.Generic;
using FastSkillTeam.BallisticRaycaster;
public class MyShooter : MonoBehaviour
{
public Transform muzzle;
public LayerMask layers;
public float muzzleVelocity = 100f;
public Vector3 gravity = new Vector3(0, -9.81f, 0);
public float maxTime = 3f;
public float dt = 0.02f;
readonly List<Vector3> points = new List<Vector3>(256);
void Fire()
{
if (BallisticRaycaster.BallisticRaycast(
start: muzzle.position,
dir: muzzle.forward,
muzzleVelocity: muzzleVelocity,
gravity: gravity,
maxTime: maxTime,
dt: dt,
maxRange: Mathf.Infinity,
layers: layers,
triggerInteraction: QueryTriggerInteraction.Ignore,
selfRoot: transform,
out RaycastHit hit,
out float timeToHit,
outPoints: points,
maxPoints: 256))
{
// Use hit and timeToHit; points contains the curved path
}
}
}
That’s it. You can use DemoGun as a reference implementation or drop in
BallisticRaycaster in your own systems for gameplay and VFX.