I already attempted to calculate some stuff based off the Model:GetExtentsSize(), but unfortunately I either fell too short, or went way to high above the character.
I need some advice on how to place the NameTag (which is parented to the Head BasePart) just where the bounding box ends on top of the Character.
Solution I tried:
I tried doing this, but realized that I basically hard coded it to the look of my Character, and it ended up being way to high in terms of offset on Players who have a smaller bounding box.
local Math = workspace.Player:GetExtentsSize() / workspace.Player.Head.Size.Y * 0.6
NameTag.StudsOffset = Vector3.new(0, Math, 0)
This might be quite technical, and requires math, so I appreciate any help you people can provide. Thanks in advance.
p.s: Please let me know if Iām missing details, I donāt do this often.
Alright, last bump and Iām hoping that someone will see this post, and possibly help. I understand at itās technical, and if you have a general idea as to a solution, please chat anyway and we could probably figure something out.
It seems that it does an OK job, but the bigger the avatar, it seems to offset less and less until it eventually falls too short to be able to go over the bounding box with that math. Thatās why I tried compensating, but unfortunately it overshoots with smaller characters.
Uh, it wasnāt before, but I just made it do that. It seems to just sit slightly off centre. Is there anyway to make it work from the head instead of the HumanoidRootPart? It might be a bit strange to have it located there instead of the head (as the game also supports VR, and it should follow the head instead)
I did have to make a few edits though to get it working with my setup, and the below code should do just that.
local Character: Model = Player.Character
local Head: BasePart = Character:WaitForChild("Head")
local HumanoidRootPart: BasePart = Character:WaitForChild("HumanoidRootPart")
local NameTag: BillboardGui = Head:WaitForChild("NameTag")
-- Doing it this way appears to solve the previous issue, only with slight overshoot on smaller bounding box characters
NameTag.StudsOffset = Vector3.new(0, ((Character:GetExtentsSize().Y / 2) - (HumanoidRootPart.Position - Head.Position).Magnitude / 2), 0)
However, I did notice that for some characters, such as those with very little bounding box height (close to the default R6 avatar with no accessories), it does overshoot slightly. I donāt mind too much about that though, however if you have a solution for that, itād make it even better.
I believe a way you can solve this problem is get a default offset assuming no accessory, then adding on the excess once you got the new extents size.
local defOffsetY = 2 --> default offset
local defExtentsY = 5 --> default extents
local excess = extentsSize.Y - defExtentsY --> how much bigger the extents actually is
Bullboard.StudsOffset = Vector3.new(0, defOffsetY + excess, 0)
I mean, you did help aid me in solving an issue that has been quite a headache for me. Iām not too great at math, and I really appreciated the assistance you provided. I left the credit anyway, so if you happen to play the game at some point, youād see.