War Battle tutorial - vmath.vector3(nan, nan, nan) (SOLVED)

If my character is not movig and I fire the rocket, the infantry sprite is replaced by rocket sprite.

And this is the information a get not moving:
defold_nan

You can get NaN (Not A Number) when you do undefined operations on floating point numbers.
E.g. division by 0.

Check your values before this printout. Nan’s are very contagious, so it’s quite possible another value that became NaN before this one. Either print them out, or step in the debugger.

2 Likes

The code line was missing the condition > 0.

if vmath.length(self.input) > 0 then
self.moving = true
self.dir = vmath.normalize(self.input)
end

Thank you @Mathias_Westerdahl

1 Like