Some vector methods appear to either not function properly or simply aren’t implemented in the modern runtime. Or maybe I’m doing something wrong.
:len()
:dist() ← works if you use :distance()
:normalize()
:limit()
For example
local dist = object.position:dist(object2.position)
local steer = vec2(1,3)
local m = steer:len()
Assuming object, object2 and steer both exist and are valid vec2 objects, both return errors about expecting a number and receiving a string.
Am I doing something wrong or is the framework goofing up on me.
To elaborate further:
function Boid:align()
local perceptionRadius = self.range
local steering = vec2(0, 0)
local total = 0
local group = Boid["flock" .. self.group]
for _, other in ipairs(group) do
local distance = self.position:dist(other.position)
if other ~= self and distance < perceptionRadius then
steering = steering + other.velocity
total = total + 1
end
end
if total > 0 then
steering = steering / total
steering = steering:normalize() * self.velocity:len()
steering = steering - self.velocity
steering = steering:limit(0.1)
self:applyForce(steering)
end
end
Based on the docs I used all these methods properly but each line containing a vec method throws errors, I’m at my wits end.