About Store Forum Documentation Contact



Post Reply 
Distance between two objects
Author Message
Ogniok Offline
Member

Post: #1
Distance between two objects
Hi!

Is there any function in Esenthel which count distance between two objects? In 3D.
03-16-2010 10:53 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #2
RE: Distance between two objects
Dist(pos,pos)
03-16-2010 11:20 PM
Find all posts by this user Quote this message in a reply
Ogniok Offline
Member

Post: #3
RE: Distance between two objects
Thanks
03-17-2010 04:21 PM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #4
RE: Distance between two objects
ehh..
i have 2 Flt values.
-0.555 and -0.666
so this gives me strange things.

Flt dist = Dist(-0.555,-0.666);
if (dist>0.7){
//This runs here
//it returns 0.867
}
(This post was last modified: 08-25-2010 09:38 AM by b1s.)
08-25-2010 09:34 AM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #5
RE: Distance between two objects
Dist flt x flt y works as calculating the distance from 0,0 point to x,y point

What you want is

Abs(x-y)
08-25-2010 10:05 AM
Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #6
RE: Distance between two objects
okay.. i couldnt figure this thing out either..
im trying to figure out if an object is in front of another object.

Vec rstart = enem->pos(); //enem pos
Vec rend = playa->pos()-rstart; //direction the player is from enem

i tried this:
Flt r = rend.z;
Flt m = enem->matrix().z.z;
Flt dist=Abs(r-m);

this did not do the trick.. i guess im a bit off base here.. could you point me to the right direction here.
hmm.. i might have this working now... not sure tho grin
(This post was last modified: 08-25-2010 11:30 AM by b1s.)
08-25-2010 11:13 AM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #7
RE: Distance between two objects
Well you can use this:

PHP Code:
if(AbsAngleBetween(Plr.pos()-head.pos,head.dir)<=DegToRad(50)) 
plr = Players[0]
head = enemy

There is always evil somewhere, you just have to look for it properly.
(This post was last modified: 08-25-2010 11:33 AM by Dynad.)
08-25-2010 11:31 AM
Visit this user's website Find all posts by this user Quote this message in a reply
b1s Offline
Member

Post: #8
RE: Distance between two objects
thanks.. this is much better!.. dont know whats going on in my head today grin
08-25-2010 11:39 AM
Find all posts by this user Quote this message in a reply
Dynad Offline
Member

Post: #9
RE: Distance between two objects
You're welcome smile

There is always evil somewhere, you just have to look for it properly.
08-25-2010 11:43 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Zervox Offline
Member

Post: #10
RE: Distance between two objects
I've noticed that the DegToRad(50) only goes one way, to get the other way I needed DegToRage(-50) as well. : o
08-25-2010 04:12 PM
Find all posts by this user Quote this message in a reply
Driklyn Offline
Member

Post: #11
RE: Distance between two objects
^^ You must be using AngleBetween, not AbsAngleBetween.
08-26-2010 06:51 AM
Find all posts by this user Quote this message in a reply
Post Reply