Per the documentation there are two options for angleBetween.
math2d.angleBetween( v1, v2 )
math2d.angleBetween( x1, y1, x2, y2 )
Using SSK2 and NOT the math2d plugin ({ math2DPlugin = false })
It seems that per this doc you can pass it either 2 or 4 parameters, which I think is not correct.
Since the function has two parameters (function( vec1, vec2 )) I doubt that I can pass 4. This could however be a bad interpretation.
I have 2 sprites on screen (at random X/Y) and want to find the angle so I can put a sprite in between connecting them. Eg: Like a ladder, I am looking to determine the angle, and then I’ll rotate the sprite to match the angle.
(I’ll then probably use distanceBetween to change the length).
There isn’t a sample in SSK2 that uses angleBetween, and no actual examples in the doc other than the 2 lines above. I did see some vector code and the below is an example of that, this causes an error per below.
local vec1 = {grid[54].x,grid[54].y}local vec2 = {grid[82].x,grid[82].y} print("XY:"..grid[54].x .. "|"..grid[54].y) print("XY:"..grid[82].x .. "|"..grid[82].y) myangle = ssk.math2d.angleBetween( vec1, vec2 ) print(myangle)
XY:490|350
XY:140|140
ERROR: Runtime error
ssk2/math2d.lua:419: attempt to perform arithmetic on field ‘x’ (a nil value)
I’m sure I’ve overlooked something simple, but with the docs and working through tests like the above, I can’t seem to come up with it.
Thoughts?