• Overhead display problem
    5 replies, posted
Thats what happends when a person crouchs, i dont like this position, it should not be stuck in player or be behid him as it does. My code is down below, help me please, comments on code could be provided ( if you want to) https://files.facepunch.com/forum/upload/149560/b8f1736a-d322-421d-a6d0-38c614f5ee18/image.png local function DrawName( ply )   if ( !IsValid( ply ) ) then return end   if ( ply == LocalPlayer() ) then return end   if ( !ply:Alive() ) then return end   local Distance = LocalPlayer():GetPos():Distance( ply:GetPos() )   if ( Distance < 200 ) then     local offset = Vector(0, 0, 23)     local ang = LocalPlayer():EyeAngles()     local pos = ply:EyePos() + offset + ang:Up()     ang:RotateAroundAxis(ang:Forward(), 90)     ang:RotateAroundAxis(ang:Right(), 90)          cam.Start3D2D(pos, Angle(0, ang.y, 90), 0.25)       local nick, plyTeam = ply:Nick(), ply:getDarkRPVar("job")       draw.DrawText(nick, "gbeorgHUDA2", 1, 2, Color(255,255,255), TEXT_ALIGN_CENTER)       draw.DrawText(plyTeam, "gbeorgHUDA2", -1, 30, Color(31,174,233), TEXT_ALIGN_CENTER)     if ply:getDarkRPVar("HasGunlicense") then       surface.SetDrawColor(255, 255, 255, 255)       surface.SetMaterial(pageMat)         surface.DrawTexturedRect(-9, -17, 16, 16)       end           cam.End3D2D()   end end hook.Add("PostPlayerDraw", "DrawName", DrawName)
You could see if the player is Player/Crouching and then adjust the positions
Man, can u give me an example code for Player:Crouching, i ve tried it previously but had some errors.
if LocalPlayer():Crouching() then --set new pos & ang else --set normal pos & ang end I would have done it that way but I am not sure if it is practical at all or if it work that way, you could alternatively see how other 3d2d hud scripts do it.
Maybe its best to use attachments/bones to get the correct position. One way is doing this: [lua]local headPos local boneIdx = ply:LookupBone("ValveBiped.Bip01_Head1") if boneIdx ~= nil then headPos = ply:GetBonePosition(boneIdx) + Vector(0, 0, 14) else headPos = ply:GetPos() + Vector(0, 0, ply:OBBMaxs().z + 4) end -- headPos should contain the correct position if such bone exists, otherwise fallback is player pos + hull.[/lua]
maybe i made smth wrong, or i should add smth to your code, but it doesnt work, (i tried configuring the vectors)
Sorry, you need to Log In to post a reply to this thread.