I have setup a weapon that has a limited range, attached to the projectiles is a script which after x amount of seconds destroys the game object. The problem with this is if you quickly move backwards as you fire you can increase the range of the weapon. Is there a better way to guarantee the distance the projectiles will travel before being destroyed rather than doing it by time?
You could just get the start position and then check the distance in the update, but it’s kind of an expensive function. Time is a lot cheaper. If there were a lot of shells flying, it might slow down your game. You can use square magnitude, which is a little cheaper. You just find the distance you want and square it, and then use square magnitude to find the distance each frame.