Skip to content
Permalink
Browse files
Tnt: Avoid divide-by-zero errors in calc_velocity()
  • Loading branch information
paramat committed May 8, 2016
1 parent b36b154 commit e7a55734d3de051d6565ebe28a9dd53043f9b352
Showing 1 changed file with 5 additions and 0 deletions.
@@ -110,6 +110,11 @@ end


local function calc_velocity(pos1, pos2, old_vel, power)
-- Avoid errors caused by a vector of zero length
if vector.equals(pos1, pos2) then
return old_vel
end

local vel = vector.direction(pos1, pos2)
vel = vector.normalize(vel)
vel = vector.multiply(vel, power)

0 comments on commit e7a5573

Please sign in to comment.