eye trace?

I was just wondering can i find the method in sandbox where when it looks at someone it displays their name?

or if you could just give me some sample code that would suffice to. Thanks in advance.

You can use Player:GetEyeTrace() which will do a trace to whatever you’re looking at. Then use draw.DrawText() to draw their name when a player is visible.

I believe this is the area where the base gamemode has the code on how it displays the players name and health as a percentage. This can bee commonly seen in the sandbox gamemode.

link

Are you JSharpe?

Something like this should work clientside:



local plyEyeTrace = LocalPlayer():GetEyeTrace()  
local eyeTraceEnt = plyEyeTrace.Entity()     

if eyeTraceEnt:isValid() then                    
    if eyeTraceEnt:isPlayer() then                 
        -- code to draw text goes here
    end
end


To draw the player’s name over their heads, you would have to get the entity’s position using ent:GetPos() and determine where to draw the text relative to the local player’s position.

Yes.