I Need Help

Posted by DevonX on Jan. 15, 2007, 4:04 p.m.

Alright, for something new that I'm working on I need to have a script for d3d_point_distance to find the distance between to points in 3D space. So I thought it was be an easy little bit of trig.

But as you can guess by this blog. It's not that easy, I'm sure some of you out there might be like, "you dumbass, thats wicked easy to do." So to those people, other than calling me an idiot, just post the code to the script below, anyone else that wants to help can also post.

As you know from my past, I'm not the most efficient person, so I'll try my best to pick out the most efficient script so I can get maximum speed out of this. Thnx to anyone who can help.

Also, does anyone know a formula to get the direction between two points with 0 degrees being to the right. This is not for GM so nobody say "point_direction(x1,y1,x2,y2);". This is pretty cool what I'm working on, its a little game where you can fly a remote controled plane, there are no objectives yet, but I have quite a bit done for one day. And you could probably guess since I need a d3d_point_distance(); script that this is 3D. And the answer to that question is yes. And I have the tilting for the plane almost perfect. Theres just one glitch though, sometimes when you point slightly downwards, you come flying back towards the camera, I have no idea what it is that is causing this, but I hope I find it. So, thnx again to anyone who supplys a d3d_point_distance(); script.

Comments

DevonX 17 years, 11 months ago

oh wait….

dist=sqrt(power(x1-x2,2)+power(y1-y2,2)+power(z1-z2,2));

would this work^^^?

Bryan 17 years, 11 months ago

return sqrt( sqr(x2-x1)+sqr(y2-y1)+sqr(z2-z1 ) )

DevonX 17 years, 11 months ago

pretty much the same thing, but ok!

DevonX 17 years, 11 months ago

bryan, ur avatar makes all of ur comments look so cheerful