So an {x, y}
object is not a vector by default? Probably that’s why some vector functions do not work with them?
I was trying to get the distance between a shells impact point and the catapult in Summit’s Gate, with varying results:
loop:
shell = self.findNearest(self.findEnemyMissiles())
catapult = self.findNearest(self.findByType("catapult"))
if shell and catapult:
self.say(shell +" "+ shell.targetPos.distance(catapult.pos))
This gives a certain value in the first few seconds, then it gives an error: “Cannot read property ‘distance’ of undefined”
I tried to make the first object a vector:
self.say(shell +" "+ Vector(shell.targetPos).distance(catapult.pos))
This gives sometimes a NaN
result, but if it “catches” a spear, I get a value.
I’m probably confusing things, but the situation is far from clear…