• Overhead player HUD follow while turning and crouching
    2 replies, posted
Hello! I'm trying to draw playertext to the right of the player but have it follow the angle and position of the player as they turn. I have the text being drawn and it works fine, but the only two issues I have are having the position do not follow the bone when crouching, and it does not follow the player when turning, it just stays in the fixed position. I have worked with math here and there, but just can't figure it out. Here's what I have: https://i.gyazo.com/d330e71f89f018748bd948514d5f3a58.mp4 local function DrawName( ply )     if ( !IsValid( ply ) ) then return end     if ( !ply:Alive() ) then return end         local offset = Vector( 0, 20, 50 )         local ang = LocalPlayer():EyeAngles()         local pos = ply:GetPos() + offset + ang:Up()         ang:RotateAroundAxis( ang:Forward(), 90 )         ang:RotateAroundAxis( ang:Right(), 90 )         cam.Start3D2D( pos, Angle( 0, ang.y, 90 ), 0.25 )             draw.DrawText( ply:GetName(), "rpname", 2, 2, color_white, TEXT_ALIGN_CENTER )             draw.DrawText( ply:GetNWString("usergroup"), "job", 2, 18, color_white, TEXT_ALIGN_CENTER )         cam.End3D2D() end I want the text to follow as the user turns, and follow the head bone down when crouching. Any tips would be a huge help! Thank you!
You can't really use an offset for this type of thing, you have to use the angle normals and then multiply them until you get what you want. (e.g ang:Up() * 10) So in this case you should try something like: local pos = ply:GetPos() + (ang:Up() * 50) + (ang:Forward() * 20) And just play around from there.
Oh my god, I don't know why this didn't make sense to me. Obviously a fixed offset is just going to sit in one spot, but using multiplication or division will move accordingly. Thank you!
Sorry, you need to Log In to post a reply to this thread.