Finding distance, square root, hypotenuse

Math.sqrt(Math.abs(AA) + Math.abs(BB))

Plug this into an Expression module being fed the X/Y distances between two objects to find the direct distance/hypotenuse, basically the pythagorean theorem. Example of what I mean here: http://www.flowlab.io/game/play/881148

Just posting because the user guide (http://flowlab.io/behavior_handbook/#logic-math-expression) doesn’t list all the expressions you can use, in particular square root/sqrt wasn’t displayed, but flowlab seems to use the same syntax as https://www.w3schools.com/jsref/jsref_obj_math.asp and it works. I also haven’t seen any posts about squaring numbers ( you use Math.sqrt(A) ), so maybe this will help others looking for the same thing, title also includes some search tags.

2 Likes