Next that follows the user's eyes

Hey guys I was just curious how I could get text on an entity that follows the players eyes. If anyone could help me I’d be very grateful! Thanks in advanced

It’s fairly simple, you just need to draw some text in a

cam.Start3D2D function, but you need to rotate the angles for a while until you can get it to work… I’m sure it won’t be hard to find an example on how to do that

I put this together fairly quickly, so it may have a bug.


local pos = self:GetPos()
local ang = self:GetAngles()

ang:RotateAroundAxis( ang:Up(), 90)
ang:RotateAroundAxis( ang:Forward(), 0)

cam.Start3D2D(pos + ang:Up(), Angle(1, LocalPlayer():EyeAngles().y-90, 90), .25)
    draw.DrawText("Hello World", "SomeFont", 0, -190, Color(255, 0, 0, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER, 1, Color(25, 25, 25, 100))
cam.End3D2D()

9/10 ^

If the text should be a constant size, it might be better to draw it in 2D via

Vector:ToScreen and

draw.SimpleText (or the other text drawing functions)