I’m not very good with vectors so I just need a little help. I am parenting a hat to the player and with the current code the hat is slightly in the wrong position. How would I set the position of the hat so that it is 10 units in the direction that the player is facing? Currently I am using the tf2 hat code, but I just need the hat to move slightly towards where the player is facing, any ideas? Thanks
[lua]
if owner:GetRagdollEntity() then
owner = owner:GetRagdollEntity()
elseif not owner:Alive() then return end
local boneindex = owner:LookupBone("ValveBiped.Bip01_Head1")
if boneindex then
local pos, ang = owner:GetBonePosition(boneindex)
if pos and pos ~= owner:GetPos() then
self.Entity:SetPos(pos + ang:Forward()*1 + ang:Right()*-1.5)
ang:RotateAroundAxis(ang:Right(),-85)
ang:RotateAroundAxis(ang:Up(),270)
self.Entity:SetAngles(ang)
self.Entity:SetMaterial("\models\gmod_tower\majorasmask.mdl")
self.Entity:DrawModel()
return
end
[/lua]