leopardpm wrote:looked at your demo - really nice! and yes, the problem is with the slope function... you can tell because the demo works when the block is in the 0 to 180 degree field from the mouse.... 181 - 359 degrees cannot compute correctly.... I would have to think, but my guess is that if ydiff OR xdiff is negative, then the signs of both have to be changed.... just a quick off the top of my head gut response though... i dont trust it! lol
Looks like you were right. All it took was using the absolute values in the angle calculation.
atan2(ydif, xdif)*(180 / 3.14)
atan2(abs(ydif), abs(xdif))*(180 / 3.14)