Making a hud that allways faces the client (Entity)

Is there a way of making a hud on a entity that allways faces the client? I’ve done alittle so far, but it only gets the LocalPlayers EyeAngle…


function ENT:Initialize() end
function ENT:Draw()

local Pos, Ang = self:GetPos() + Vector( 0, 0, 8 ), Angle(0, EyeAngles().y, 0) -- sets the EyeAngle.
Ang:RotateAroundAxis( Ang:Right(), 90)
Ang:RotateAroundAxis( Ang:Up(), -90)

local TextWidth = surface.GetTextSize("Baking bucket")

if Pos:Distance(LocalPlayer():GetPos()) < 100 then -- If you go too far away, it wont display.
	cam.Start3D2D(Pos + Ang:Up(), Ang, 0.11)
		draw.RoundedBox(4, -TextWidth*0.5 - 3, -86, TextWidth + 12, 30, Color(0, 0, 0, 230))
		draw.WordBox(2, -TextWidth*0.5, -90, "Baking bucket", "HUDNumber5", Color(0, 0, 0, 0), Color(255,255,255,255))

function ENT:Think() end

As you see here the hud just turns too much, witch look dumb.

Anyone :slight_smile: Help is really appreciated!

Angle(0, EyeAngles().y, 90)

Thanks, but im not looking for make it look like this…

Just play with the angle… Angle(0, EyeAngles().y, 0) removed the 90

The angles roll value will do that, I left that for you to play with :stuck_out_tongue:

Lol. Anyway, what i mean it the post is that i want the hud to face the pos of client.

Forgot to add this in:
local pos = ent:GetPos()
local ang = EyeAngles()

ang:RotateAroundAxis(ang:Forward(), 90)
ang:RotateAroundAxis(ang:Right(), 90)

cam.Start3D2D(pos, Angle(0, ang.y, 90), 1)

Thats not what i said!? What you made their is the hud getting the EyeAngle of a player, and not a hud that faces the player pos??

That code will make the text constantly face your eyes.

Yes, but thats not what im asking for.

[editline]5th March 2014[/editline]

Im asking for a way, to make the HUD face the current pos of a player?

Sorry I have no idea what you’re talking about.

Show an example with a picture or explain it differently

Get it now?

[editline]5th March 2014[/editline]

The hud is facing the pos of the player

Yeah I see what you mean now.

This should do the trick “(entPos-plyPos):Angle()”

You could probably use ply:GetShootPos()

Edit: Nevermind…

I had to do some changes thoug :smiley:
local RotationAng = (self:GetPos()-LocalPlayer():GetPos()):Angle()
local Pos, Ang = self:GetPos() + Vector( 0, 0, 8 ), Angle(0, RotationAng.y, 0)

That works! :smiley: Thank you, can you explain what happens? What is :Angle() for?

Vector:Angle() will convert the vector into an angle, you can just check the wiki for a reference located here.

Thx, can i convert an vector in to an angle then?

That’s what you just did.

Woops, i meant An Angle to vector :smiley:

Why would you have to do that?

Everything you need is already there.