• How to see if a player is looking at an entity or ALMOST looking at the entity
    3 replies, posted
Hey guys the title says it all. I know you are supposed to use Player/GetEyeTrace, but I don't really understand how to use it properly. I tried and got a lot of odd errors. If someone can give me a quick example with a brief explanation, that would be perfect. I also looked at DarkRP's hud to do this and couldn't relate it to entities. I understand how it works for players, but I don't know what the equivalent of getting the pos of the other player would be for entities. I tried entity:GetPos but that wasn't it either. Thanks!
See the example here Vector/Dot
function IsLookingAt( ply, targetVec ) return ply:GetAimVector():Dot( ( targetVec - ply:GetPos() + Vector( 70 ) ):GetNormalized() ) < 0.95 end In this example, what would targetVec be? Would it be the position of the entity the player is almost looking at?
I'd suggest reading a bit about what a dot product is, it might help you in the future with some stuff, very useful information https://en.wikipedia.org/wiki/Dot_product
Sorry, you need to Log In to post a reply to this thread.