Fix crash

This commit is contained in:
ElCeejo 2022-08-02 20:32:41 -07:00 committed by GitHub
parent 35fb5b680e
commit da15c361cf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -112,7 +112,7 @@ local function get_avoidance_dir(self)
local vel = self.object:get_velocity()
local ahead = vec_add(pos, vec_normal(self.object:get_velocity()))
local avoidance_force = vector.subtract(ahead, col_pos)
avoidance_force = vec_normal(avoidance_force) * vec_len(vel)
avoidance_force = vec_multi(vec_normal(avoidance_force), vec_len(vel))
return vec_dir(pos, vec_add(ahead, avoidance_force))
end
end
@ -360,4 +360,4 @@ creatura.register_movement_method("creatura:obstacle_avoidance", function(self)
end
end
return func
end)
end)