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.

DarkBASIC Discussion / distance measureing

Author
Message
ClearCoder
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 2nd Jul 2003 15:14
how do you measure the distance between two objects
(note: the distance will change each loop)

thx, (this is probally really simple)
woody
Newbie Now; Expert Later
Current project:The Sorus
http://us.f1.yahoofs.com/users/8e2ce249/bc/logo.jpg?bc6XVw.ALSzFxXyM[/img]
John H
Retired Moderator
22
Years of Service
User Offline
Joined: 14th Oct 2002
Location: Burlington, VT
Posted: 2nd Jul 2003 17:30
Well first find each of their object positons, find out how far apart they are x, y and z and then with that information you should be able to fufill whatever your trying to do Subtract them from eachother and if x > -50 and < 50 then closex#=1

RPGamer

Current Project: Eternal Destiny
Questions? Comments? Suggestions? Go to the Eternal Destiny Forum!
ClearCoder
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 2nd Jul 2003 18:19
kay i found the distance just to have a bigg prob i made this code as a sort of Zelda l targeting system but when it is actived the player moves across to the target and stays horizontal
the only other bit of code that affects this is the lockangleY# which is the angle of the target which point towards you because its running after you any idea on what the problem is



thx for any help i get
woody

Newbie Now; Expert Later
Current project:The Sorus
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 3rd Jul 2003 00:12
Gamer, that's partially correct. That will generate a non-rotating cube collision box around the object, but it won't return the actual distance between 2 objects.

The 3d distance formula is as follows:
dist = ( (x1-x2)^2 + (y1-y2)^2 + (z1-z2)^2 )^(1/2)

ClearCoder
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 5th Jul 2003 14:30
yeah thats the 3d and mine only uses x and z i don't need to know the y distance

Newbie Now; Expert Later
Current project:The Sorus
Hell IVIonkey
22
Years of Service
User Offline
Joined: 1st Apr 2003
Location: Outer Limits
Posted: 5th Jul 2003 14:47
Then you'll want
dist = ( (x1-x2)^2 + (y1-y2)^2 )^(1/2)
for circle collisions.

ClearCoder
22
Years of Service
User Offline
Joined: 27th Feb 2003
Location: United Kingdom
Posted: 5th Jul 2003 15:45
look at my one and you will see that is what i have done just in a much longer way doing each process one by one

Newbie Now; Expert Later
Current project:The Sorus

Login to post a reply

Server time is: 2025-05-19 16:25:53
Your offset time is: 2025-05-19 16:25:53