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 / distance to object

Author
Message
Alphaman1101
15
Years of Service
User Offline
Joined: 1st Aug 2009
Location:
Posted: 19th Aug 2009 20:52
i need to check every loop the distance to an object if the flag stoped is set true. is there a function that will check it or what can i use as a work around. i would do object collision but i cant figure out dark gdk's collision stuff. Help Please?
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 20th Aug 2009 04:15
You could check out the dbIntersectObject command, that will return you the distance between 2 points where the distance is measured from the first point, to where the line intersects the first of the objects in the range of objects to be checked, on the way to the second point.

An easier method though would be to record the position of where you are measuring from and the position of where you are checking to and use some square root maths to find the distance..
I think its something like :



Im pretty sure thats it, but could be wrong, double check the maths to make sure before you use it...

If it ain't broke.... DONT FIX IT !!!
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 20th Aug 2009 04:24
That's almost right I think. I'm pretty sure it's suppose to be Bx - Ax. So the position you are measuring to - the position you are measuring from.

Games are like life, they should never stand still.
Matty H
16
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 20th Aug 2009 16:26
Quote: "That's almost right I think. I'm pretty sure it's suppose to be Bx - Ax. So the position you are measuring to - the position you are measuring from."


Does it matter which way round you do it?

I think that as long as you are consistent it does not matter, could be wrong though.
Mista Wilson
16
Years of Service
User Offline
Joined: 27th Aug 2008
Location: Brisbane, Australia
Posted: 20th Aug 2009 18:04
hmm im not sure, I think that it would be the same whether you measure a distance from a to b or b to a.... its not going to change lol ...

at least in my little function above, because you already know the world position of what you are checking ..... it would matter though if you were using an intersect or ray cast test, as casting from one direction will get you a different result than casting from another, depending on whats inbetween...

If it ain't broke.... DONT FIX IT !!!
heyufool1
15
Years of Service
User Offline
Joined: 14th Feb 2009
Location: My quiet place
Posted: 20th Aug 2009 18:49
Quote: "Does it matter which way round you do it?"

I guess when I think about it, it doesn't matter. It's just that's how it's always explained.

Games are like life, they should never stand still.

Login to post a reply

Server time is: 2024-11-20 17:26:51
Your offset time is: 2024-11-20 17:26:51