diff --git a/OpenRA.Mods.Common/Projectiles/Railgun.cs b/OpenRA.Mods.Common/Projectiles/Railgun.cs index 0701cef67b..79032ba6fe 100644 --- a/OpenRA.Mods.Common/Projectiles/Railgun.cs +++ b/OpenRA.Mods.Common/Projectiles/Railgun.cs @@ -153,14 +153,17 @@ namespace OpenRA.Mods.Common.Projectiles // An easy vector to find which is perpendicular vector to forwardStep, with 0 Z component LeftVector = new WVec(ForwardStep.Y, -ForwardStep.X, 0); - LeftVector = 1024 * LeftVector / LeftVector.Length; + if (LeftVector.LengthSquared != 0) + LeftVector = 1024 * LeftVector / LeftVector.Length; // Vector that is pointing upwards from the ground UpVector = new WVec( -ForwardStep.X * ForwardStep.Z, -ForwardStep.Z * ForwardStep.Y, ForwardStep.X * ForwardStep.X + ForwardStep.Y * ForwardStep.Y); - UpVector = 1024 * UpVector / UpVector.Length; + + if (UpVector.LengthSquared != 0) + UpVector = 1024 * UpVector / UpVector.Length; //// LeftVector and UpVector are unit vectors of size 1024.