Hundreds of features to explore
Games made in Construct
Your questions answered
Trusted by schools and universities worldwide
Free education resources to use in the classroom
Students do not need accounts with us
What we believe
We are in this together
World class complete documentation
Official and community submitted guides
Learn and share with other game developers
Upload and play games from the Construct community
Game development stories & opinions
Problem Description
Unless the distance expression shouldn't give back the distance between two points, I think this expressions result ist wrong.
round(distance(Pos1.X, Pos2.X, Pos1.Y,Pos2.Y))[/code:1y391j78] [u]compared to[/u] [code:1y391j78]round(sqrt(abs(Pos1.X - Pos2.X)^2 + abs(Pos1.Y - Pos2.Y)^2))[/code:1y391j78] This - IMHO correct way to calculate the distance - gives a very different result using the distance expression. [b]Operating System and Service Pack[/b] Win7 SVP3 [b]Construct 2 Version ID[/b] 163
Not a bug.
The correct way to use the distance function is:
distance(Pos1.X, Pos1.Y, Pos2.X, Pos2.Y)[/code:1czenn2n] Notice the x,y pairs are next to each other. It's exactly the same as: [code:1czenn2n]sqrt((Pos2.X - Pos1.X)^2 + (Pos2.Y - Pos1.Y)^2)[/code:1czenn2n] or [code:1czenn2n]sqrt((Pos1.X - Pos2.X)^2 + (Pos1.Y - Pos2.Y)^2)[/code:1czenn2n] The abs() isn't needed since any number squared is always positive.
Develop games in your browser. Powerful, performant & highly capable.
Ahh, my bad, sorry, sorry, sorry -> ashamed in the leftmost corner.... (the eyes, old eyes, small screen, high resolution )
Thanks R0J0hound. I'll try to delete or let this thread delete.