Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / okie finding some distance

Author
Message
Oneka
20
Years of Service
User Offline
Joined: 24th Apr 2004
Location: Hampton,VA
Posted: 6th May 2004 02:10
Ok Iam making a attack code but how do you find the distance between a enemy and the player?

A 1 man team
GameKit
21
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 6th May 2004 17:26
The distance formula is...

Distance=Sqrt((X1-X2)^2+(Y1-Y2)^2+(Z1-Z2)^2)

So the code you need would look something like...

Dist=Sqrt((Object Position X(1)-Object Position X(2))^2+Sqrt((Object Position Y(1)-Object Position Y(2))^2+Sqrt((Object Position Z(1)-Object Position Z(2))^2)

...Well... I hope I helped

Previously known as "Game_Creator". Thou shalt not thwart the way of the dragon. For thou tasteth like chicken.
Chris K
21
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 6th May 2004 21:34
It's just Pythagoras's Theorem

Login to post a reply

Server time is: 2024-11-26 17:28:59
Your offset time is: 2024-11-26 17:28:59