Raised This Month: $12 Target: $400
 3% 

[ H3LP ] Check entity in origin distance


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
DarthMan
Veteran Member
Join Date: Aug 2011
Old 10-18-2017 , 05:45   [ H3LP ] Check entity in origin distance
Reply With Quote #1

Hello. How can I check the closest entity in an origin distance? Like if I use vector_distance from point1 to point2, I wanna get the closest entity from that vector distance.
DarthMan is offline
KiLLeR.
Senior Member
Join Date: Jul 2014
Location: Bulgaria
Old 10-18-2017 , 06:06   Re: [ H3LP ] Check entity in origin distance
Reply With Quote #2

Loop through all entities in this distance and keep only the closest one in variable.
KiLLeR. is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-18-2017 , 06:37   Re: [ H3LP ] Check entity in origin distance
Reply With Quote #3

Use Find entity in sphere and check who got the closest distance
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
DarthMan
Veteran Member
Join Date: Aug 2011
Old 10-18-2017 , 06:50   Re: [ H3LP ] Check entity in origin distance
Reply With Quote #4

Quote:
Originally Posted by Natsheh View Post
Use Find entity in sphere and check who got the closest distance
I used find entity in sphere, but I don't know how to get them in a line from fOrigin to fRet. So this acts like a TraceLine, and I only want to look at entities from that line. If I user vector_distance the normal way it won't work as I want to. I can try getting all entities origin, and check if there is a close distance between the entity origin and fRet, but, wouldn't that check it in a sphere? Like it can return a wrong entity.
DarthMan is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 10-18-2017 , 08:15   Re: [ H3LP ] Check entity in origin distance
Reply With Quote #5

Quote:
Originally Posted by DarthMan View Post
I used find entity in sphere, but I don't know how to get them in a line from fOrigin to fRet. So this acts like a TraceLine, and I only want to look at entities from that line. If I user vector_distance the normal way it won't work as I want to. I can try getting all entities origin, and check if there is a close distance between the entity origin and fRet, but, wouldn't that check it in a sphere? Like it can return a wrong entity.
PHP Code:

new Float:MaxDistance 500.0Float:fDistance;
new 
entFloat:origin_1[3], Float:origin_2[3], iTarget;
while( (
ent engfunc(EngFunc_FindEntityInSphereentorigin_1MaxDistance) > 0)
{
      
pev(entpev_originorigin_2)
      if((
fDistance get_distance_f(origin_1origin_2)) < MaxDistance)
      {
                 
iTarget ent;
                 
MaxDistance fDistance;
      }


Origin_1 is where your point 1 is located
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 10-18-2017 at 08:17.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:11.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode