• Detect if ply2 sees ply1's face
    10 replies, posted
Hello dear's! Can you explain, or show code, how i can check this? Visually i understand, but can't write it. https://files.facepunch.com/forum/upload/144752/dbbbe2bb-3d29-4613-b41f-4fb72828a612/ApplicationFrameHost_2018-03-13_16-14-53.png
You need to use GetEyeTrace and check bone name
Yep, but ply2 must place crosshair on head, i think it not true...
So you want to make "Is ply1 on screen"?
ply's 1 face on screen, and not work if head from spine
I think, Vector:ToScreen will help you
Also it must be serverside, now i have this code function SWEP:IsLookingAt( ply ) local yes = ply:GetAimVector():Dot( ((self.Owner:GetPos()+Vector(0,0,75)) - ply:GetPos() + Vector( 70 ) ):GetNormalized() ) return (yes > 0.4) end but it work from spine...
Do a line trace from player 1's eyepos to player 2's and see if the way is clear.
Use GetBonePos and LookupBone with the valve biped head bone. This is ValveBiped.Bip01_Head.
function IsLookingAt(ply, targetVec) -- Retrieved from the Garry's Mod wiki return ply:GetAimVector():Dot((targetVec - ply:GetPos() + Vector(70)):GetNormalized()) < 0.95 end function CanSeeFace(ply_1, ply_2) return IsLookingAt(ply_1, ply_2:EyePos()) end
You can also use a util.GetPixelVisibleHandle whose visibility you can get by util.PixelVisible - it's client side so you'll have to network it to the server if you want to make use of it server side, along with perhaps a trace to make sure the client isn't 'cheating' somehow like suggested above. the above method (using just the trace) will return true if the player is behind some opaque entity without a physbox to collide with
Sorry, you need to Log In to post a reply to this thread.