Having a problem with my 3d2d text on my door being misaligned. Any idea how to fix this?
https://i.imgur.com/mLBkKzh.jpg
local door = FindMetaTable("Entity")
function door:DrawDoorInfo()
if !self:IsDoor() then return end
if self:GetNetVar("title") == "" or self:GetNetVar("title") == nil then return end
local pos, ang, posBack, angBack, width, hitWorld = CalculatePositioning(self)
cam.Start3D(EyePos(), EyeAngles())
--ang:RotateAroundAxis(self:GetAngles():Up(), 90)
local tsX, tsY = surface.GetTextSize(self:GetNetVar("title").."12")
cam.Start3D2D(pos + Vector(0,0,25), ang, 0.12)
surface.SetFont("TargetID")
draw.SimpleText(self:GetNetVar("title") .. "12", "TargetID", tsX+tsX/2, 25, Color(255, 255, 255, 255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_RIGHT);
cam.End3D2D()
cam.Start3D2D(posBack + Vector(0,0,25), angBack, 0.12);
draw.SimpleText(self:GetNetVar("title") .. "12", "TargetID", tsX+tsX/2, 25, Color(255, 255, 255, 255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_RIGHT);
cam.End3D2D()
cam.End3D()
return true
end
Try TEXT_ALIGN_CENTER
It just shifted it to the right more
Oh, lol the problem is tsX+tsX/2, change + to -
When using TEXT_ALIGN_CENTER with tsX-tsX/2 it still has the text cut off. When using TEXT_ALIGN_LEFT with tsX-tsX/2 the text is still too far to the right.
bump
There is no error, you just have to change positions/text alignment
The second picture you posted is fine. Those are two different entities so unless you make an exception using the MapCreationID(), it'll look just like that no matter what you do, unless you're willing to ruin every other door.
Well how do the other addons accomplish such a thing as to get it working perfectly on every door.
did you see someone do this one perfectly? Also you could theoretically try to find entities around and try to calculate using boundaries whether they can be counted as "double doors" and then use the middle point between the two, maybe there's some sort of function out there that I am not aware of.
Have you tried
draw.SimpleText(self:GetNetVar("title") .. "12", "TargetID", tsX/2, 25, Color(255, 255, 255, 255), TEXT_ALIGN_RIGHT, TEXT_ALIGN_RIGHT);
And then just adjusting your vector in Start3D2D
Thats what I'm having trouble with. calculating the vector is a pain because I can't just add some simple addition or subtraction, because what if another door who is flipped 180 degrees, then I have to work with that too. I am wondering how I can maybe improve the door calculation vector function I posted a 3 posts before.
bump
Try changing the font size. Or using a different name for the door so that it's shorter.
I don't think you guys understand. I need help with the positioning of the 3d2d camera. It isn't the text positioning.
bump
Change Font Size, change 2D3D X & Y positions.
You don't understand... if you can't even understand what we're saying. Is this even your code? Or do you even code?
I don't think you understand. I can't just add or subtract the x or y value. It depends on the position of the door. If I add a certain amount to the vector and one one door it moves more to the center, on another door with facing the opposite side, it'll go further away. Also, what even gives you the impression I don't know how to code? I damn well know how to code and just because some people can't really understand my problem (which I don't blame them) doesn't mean I can't code just because I can't explain something well.
w h e n y o u s t a r t t h e c a m e r a y o u a r e g i v e n x a n d y p a r a m e t e r s.
You're explaining it just fine, I think. You can change things that depend on other things. It goes a little like this
local newX = initialX - 20
Sorry, you need to Log In to post a reply to this thread.