I have a game where the guns have a default speed and the bullets have speed modifiers depending on ammo type. Each bullet type has a destroy timer which caps the range.
Different combinations of guns and bullets create different ranges.
I am trying to figure out how I can instantly calculate the range of the weapon and bullet combo before it is actually fired so the ai knows their range as soon as they swap weapons
Code the bullet uses to move:
transform.Translate(0, bulletSpeed, * bulletSpeedModifier * Time.fixedDeltaTime, 0)
Code to destroy bullet:
if (destroyTimer < Time.time)
{
Destroy(gameobject);
}
//Destroy timer is initialized in the start method of the bullet when the bullet is initialized
I previously was simulating a bullet being fired when the weapon was swapped to get the range but this was a bit too slow in some situations and the ai would need to wait before they knew the range
Any clever tricks would be appreciated