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.

Dark GDK / detect distance

Author
Message
Ondrej
16
Years of Service
User Offline
Joined: 18th Apr 2008
Location: Slovakia
Posted: 6th May 2008 11:57
How can I detect a distance from camera toward object, because use function dbPickObject( ) and dbGetPickDistance( ) is very slow.

cout << sorry for my bad english;
RancidRat
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 6th May 2008 13:01
Here is a function I use. you can put at the top



example to use it:

getdistance(2);

this will return the distance between the default camera and object number 2.

havnt tested it.
Ondrej
16
Years of Service
User Offline
Joined: 18th Apr 2008
Location: Slovakia
Posted: 6th May 2008 13:25
But I need variabile function, which will detection object in far and detection distance between object and camera.

cout << sorry for my bad english;
jason p sage
17
Years of Service
User Offline
Joined: 10th Jun 2007
Location: Ellington, CT USA
Posted: 6th May 2008 21:05
You should be able to work that out from the code snippet you just got here..

store the distance and check if its within your "desired range" is all.. unless I'm missing what you are looking for....

Core2uu
16
Years of Service
User Offline
Joined: 15th Mar 2008
Location: Saskatoon, SK, Canada
Posted: 7th May 2008 07:13
Quote: "Here is a function I use... havnt tested it."


If it's a function you use how come you haven't tested it yet?

~~It's not who you are underneath, but what you do that defines you.~~
RancidRat
16
Years of Service
User Offline
Joined: 19th Feb 2008
Location:
Posted: 7th May 2008 09:23
lol... yeah... what I mean is... I usually get the distance between two objects getdistance(object 1, object 2); I just put dbCameraPosition in the snippet instead of dbObjectPosition, so i did not test it like that.

Ondrej you can say something like:

if (getdistance(enemy) < 200)
{
enemyShootsPlayer();
}
Ondrej
16
Years of Service
User Offline
Joined: 18th Apr 2008
Location: Slovakia
Posted: 8th May 2008 01:53
Do function which count distance between 2 object isn't problem, but I'm missing function which detect object, the crosshair is showing on object

like that:

int object = getObject(dbScreenWidth()/2, dbScreenHeight()/2);

cout << sorry for my bad english;

Login to post a reply

Server time is: 2024-09-29 19:19:57
Your offset time is: 2024-09-29 19:19:57