bool:IsEntVisible
If I can make it better let me know
almost totally inspired and based on code from this forum # requires SMLib Code:
/** |
Re: bool:IsEntVisible
You should say that it requires SMLib. Also, when comparing distances without needing to know the exact distance, you can avoid a square root, which is a "somewhat heavy" math operation. To do so you'll need to pow2 on the other side of the comparison. Using SMLib you can't optimize that.
See https://sm.alliedmods.net/api/index....d=show&id=547& (third arg and SMLib source code for more info). |
Re: bool:IsEntVisible
So if I'll square argument for compare with squared result then function will be lighter?
|
Re: bool:IsEntVisible
I changed the wording in my last post, to make it clearer.
Yes, it is better to square an operand than to square-root the other operand. |
Re: bool:IsEntVisible
I don't find this useful (and somewhat wrong and confusing) for the following reasons:
-It requires smlib -The player's abs origin is at his foot, giving you a falsely false result most of the time (you define this as the default origin to use) -To elaborate on that, you're also using the abs origin of the target entity (regardless of the ground hit issue, on bigger objects this can lead to issues) -I haven't looked up if the mask triggers on hitbox or on vphysics collision (and stuff like glass), but imagine a different scenario based on a small entity just happening to be between the players. I have the following suggestions to make this useful to others as a snippet: -Remove the smlib requirement -Add in a fov check before the trace ray (because it's a snippet and you don't know how many times random AM user xyz may call this) -Make the trace ray optional (because a simple fov check might be just as useful) -Maybe make it being hit only by world (and maybe bigger props?) -Pick better starting/end points. (Either eye positions for clients or hitbox midpoints for entities) -Instead of end points, just use the client's eye-angles. Imagine a player being half-way behind a wall with the end position being obscured by it, even though the player can be seen? |
Re: bool:IsEntVisible
Work with looking at player from something box(model)/brush(door)?
|
| All times are GMT -4. The time now is 18:37. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.