3D2D buttons hitbox moving based on players angle..?
2 replies, posted
Making an addon, and one of my entities has 3D2D buttons for it's interaction. If i'm directly infront of the button, it works fine, while if i move angle, the hitbox moves away from the top of the button. I don't really know how to explain it so I drew up a quick "diagram".
In the first one, the button is in the correct place, with the trace picking it up fine and it being rendered fine.
In the second one, ply moves across, and while the visual side is fine, the hitbox for the button (Part in red) moves. Not sure if this is to do with the trace not responding correctly with the players new angle or what.
I know it's not explained very well, so if you need to ask anything else just ask. Thanks.
(Btw, when I say "Hitbox", i mean the entity checking the trace pos and if it's in the bounds of the button)
I'm assuming you already coded something, if so you should post it so people can actually fix the issue.
It's just a simple bit of trace code in the 3D2D. I can't show too much for private reasons, but i'l try to show the parts you'll need.
local ang = self:GetAngles()
local lpos = Vector(10.75, -11.8, 38.7)
local pos = self:LocalToWorld(lpos)
local w,h = 345,200
cam.Start3D2D(pos, ang, 0.1)
-- Draw the 3D2D stuff here.
-- Move onto the Trace.
local Trace = self:WorldToLocal(LocalPlayer():GetEyeTrace().HitPos)
if(Trace.y >= -9.1 && Trace.y <= -3.82 && Trace.x >= 23.47 && Trace.x <= 24.46) then
draw.RoundedBox(5, w * 0.05, h * 0.6, w * 0.2, h * 0.3, Color(50, 50, 50, 255))
draw.RoundedBox(5, w * 0.05, h * 0.6, w * 0.2, h * 0.3, Color(35, 35, 35, 255))
Sorry, you need to Log In to post a reply to this thread.