Getting 3D2D to face the player?

Okay, so this is my most frequently asked question regarding Lua, easily, but I still can’t figure it out.

Put simply, I’m making a damage indicator, saying how much damage I did and where it hit. The Usermessage works fine, and the thing draws fine, but I can’t get the angles right. I want it to always be facing the player. Here’s what I have:

CASHGAIN_MESSAGE_MOVERATE = {0.0005,0.01} – Fraction to move; delay in seconds
CASHGAIN_MESSAGE_FADERATE = {0.5,0.01} – How much to fade (from 255 being full and 0 being invisible); delay in seconds

function GM:PostDrawOpaqueRenderables()
for k,t in pairs(DAMAGE_INDICATORS) do
if t.Visible then
showing = true

		--local cx,cy = ScrW() * CASHGAIN_MESSAGE_POS[1],ScrH() * (CASHGAIN_MESSAGE_POS[2] - t.CurYAdd)
		local addy = t.CurYAdd
		if (CurTime()>t.NextMove) then
			t.NextMove = CurTime() + CASHGAIN_MESSAGE_MOVERATE[2]
		if (CurTime()>t.NextFade) then
			t.NextFade = CurTime() + CASHGAIN_MESSAGE_FADERATE[2]
			t.CurAlpha = t.CurAlpha - CASHGAIN_MESSAGE_FADERATE[1]
		if (t.CurAlpha<10) then
			t.Visible = false
		local ang = (LocalPlayer():GetPos() - t.Position):Angle() + Angle(0,0,0)
		--local ang = LocalPlayer():GetAimVector():Angle()
		--local ang = EyeAngles()
		local pos = t.Position
		--local pos = EyePos()
		local scale = 0.4
		cam.Start3D2D(pos, ang, scale )
		cam.Start3D2D(pos, ang * -1, scale )
		DAMAGE_INDICATORS[k] = nil -- We're not showing, so remove this message from the table.


I’ve no idea how to get it to look at me. If I do the currently uncommented “ang,” then the text is sideways, and I don’t know how to rotate it; all my attempts have put it at odd angles that don’t really get me anywhere. If anyone can help me with this, thanks.

Can you post an image of the indicator in it’s current state, I think you just need to add 90 onto the roll of the angle.

I’ll show you both normal and +90 roll. They’re both ugly. Give me 5 minutes.


Here we go.


Anyone? :raise:

This is one of the last things needed for my gamemode, except for me making additional content. I’d like to get this done as soon as possible so I can work on the finishing touches. :saddowns:

Without having tested it at all, I have found that 3d2d faces up by default, and that if 90 is added to pitch or roll, then it works fine.

On the other hand, you appear to have your angle backwards, again, without testing it at all.
[lua]local ang = (LocalPlayer():GetPos() - t.Position):Angle() + Angle(0,0,0)
–local ang = LocalPlayer():GetAimVector():Angle()
–local ang = EyeAngles()[/lua]
It seems to me that using
[lua]local ang = (t.Position - LocalPlayer():GetShootPos() ):Angle() --GetShootPos because it returns where they are looking from, probably the problem. Maybe reversed? Don’t know.
local ang = -LocalPlayer():GetAimVector():Angle()
local ang = -LocalPlayer():EyeAngles()[/lua]
It seems to me that any of those three would work, but regardless you will want to use GetShootPos, because the player doesn’t look from their feet.
Its pretty late, so I probably got the first fixed line wrong, but still GetShootPos.