Functions similar to lengthdir_x/lengthdir_y?

Hello, is there something similar to GameMaker’s lengthdir_x/lengthdir_y functions?

What does the function do?

We have a lot of functions under the vmath module name. And of course, accessing the individual elements of a vector using .x, .y, .z, .w.

1 Like

I’ve just made a module that do this:

local lengthdir = {}

function lengthdir.x(length, angle)
     local radian_angle = angle * math.pi / 180
     return length * math.cos(radian_angle)
end

function lengthdir.y(length, angle)
     local radian_angle = angle * math.pi / 180
     return length * math.sin(radian_angle)
end

return lengthdir
1 Like