AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Get entity user is aiming at (Not Solid one) (https://forums.alliedmods.net/showthread.php?t=164598)

Owyn 08-13-2011 11:44

Get entity user is aiming at (Not Solid one)
 
I want to know if user is looking directly at weaponbox, but

PHP Code:

engfunc(EngFunc_TraceLinefOldLocationfNewLocationDONT_IGNORE_MONSTERS IGNORE_GLASSidptr); 

PHP Code:

TR_pHit 

doesn't get the entity, get_user_aiming - the same.

so can anything be done?

Exolent[jNr] 08-13-2011 16:41

Re: Get entity user is aiming at (Not Solid one)
 
Do the trace from player's eyes to first get the player's aim origin as well as checking if it hit an entity.
Keep that first hit entity in a unique variable saved for later.
Then at small intervals, do a find_ent_in_sphere() check with small radius, following the trace line path.
If you find something in that sphere that is not solid, return that entity.
If you don't find anything, return the entity you found in the beginning.

Owyn 08-13-2011 16:54

Re: Get entity user is aiming at (Not Solid one)
 
Quote:

Do the trace from player's eyes to first get the player's aim origin as well as checking if it hit an entity.
what entity?

Quote:

Keep that first hit entity
it can be player or some random rare map entity, but in 99% there would be no entity that could be hit.

maybe did you mean End origin of a traceline which represents the hit of the wall?

Quote:

Then at small intervals, do a find_ent_in_sphere() check with small radius, following the trace line path.
thought about that, so for 900 units distance traceline i need to call find_ent_in_sphere() 30 times each of 30 units radius plus calculatie start origins for each sphere?

Quote:

If you don't find anything, return the entity you found in the beginning.
no really, what entity?

Exolent[jNr] 08-13-2011 17:04

Re: Get entity user is aiming at (Not Solid one)
 
Quote:

Originally Posted by Owyn (Post 1531925)
what entity?

it can be player or some random rare map entity, but in 99% there would be no entity that could be hit.

maybe did you mean End origin of a traceline which represents the hit of the wall?

no really, what entity?

When you start, get the player's eyes origin, and then do an aim vector for 9999 units.
Do a trace line, and store the end position as the player's aim origin.
Also, check that trace line to see if it hit an entity. (<--- THAT ENTITY, doesn't matter what entity it is, could also hit nothing!)
Then you will be doing your sphere checks from the eyes origin to the aim origin.


Quote:

Originally Posted by Owyn (Post 1531925)
thought about that, so for 900 units distance traceline i need to call find_ent_in_sphere() 30 times each of 30 units radius plus calculatie start origins for each sphere?

Yes.

Owyn 08-13-2011 17:10

Re: Get entity user is aiming at (Not Solid one)
 
Quote:

Yes.
that doesn't sound good, but thanks anyway :)


All times are GMT -4. The time now is 03:22.

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