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 / can somone give me some code that chcks the distance

Author
Message
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 7th Mar 2004 13:25
can somone give me some code that chcks the distance between the camera(you) and an object like a tank pls

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
hyrichter
21
Years of Service
User Offline
Joined: 15th Feb 2004
Location: Arizona
Posted: 7th Mar 2004 16:37
Dist = sqrt((object position x(x)-camx#)^2 + (object position y(x)-camy#)^2 + (object position z(x)-camz#)^2)

That's the formula for calculating distance in a 3d world, where camx#, camy#, and camz# are your camera positions.

Hope this helped you...
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 13th Mar 2004 21:41
thanks a lot hyrichter now can somone tell me if you can put somthin like if object position = 2 (like your 2 away from it) then (your command) or somthin cause i dont know what to put

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
steve c
21
Years of Service
User Offline
Joined: 30th Jan 2004
Location: united kingdom
Posted: 20th Mar 2004 17:14
help please somone i need to put somthin like if you are 2 away from object 4 or whatever and enterkey()=1 get in it somthin like that but i dont know what to put for if you are 2 away how do u do it

*=========**=================*
*.-steve-.**.-slipknot rule-.*
*=========**=================*
BearCDPOLD
21
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 20th Mar 2004 20:54
Just flip the formula around .



Crazy Donut Productions
Current Project: KillZone
Mattman
21
Years of Service
User Offline
Joined: 5th Jun 2003
Location: East Lansing
Posted: 20th Mar 2004 20:57
just do something like



change maxdist to your liking, change what you want the object should do, then change the object number to what you want.
Mason
21
Years of Service
User Offline
Joined: 20th Mar 2004
Location: Arizona
Posted: 20th Mar 2004 23:14
Hey Irish Fool, thats nice that you wanna learn, but there is a lot of tutorials in the dark basic directory that can answer a lot of your problems. I think this is your fourth post in a small amount of time? Im not trying to be rude but you will get your answer much faster that way.
cheers
xXMasonXx

Login to post a reply

Server time is: 2025-05-31 17:47:15
Your offset time is: 2025-05-31 17:47:15