I’ve been trying to make the doll from gmod position itself on the back of a player, like a backpack, but even going off other lua files similar, I just can’t seem to get it.
Could anyone please help me out? I’m not exactely experienced.
so… what’s exactly wrong?
Also, you should mention that this is for the Pointshop addon, not everyone will know that.
And a tip: you can use the PAC3 addon to position the model, then just copy the position, rotation, etc. over to your pointshop item code.
That’s how I set up all my custom pointshop models.
I think the position should be a vector relative to the bone’s position.
But yeah, I really suggest using the PAC3 addon just for getting the positions, instead of playing guessing games and getting the right position with trial and error.
Here’s my backpack code, if it helps:
ITEM.Name = 'Backpack'
ITEM.Price = 750
ITEM.Model = 'models/props_c17/SuitCase_Passenger_Physics.mdl'
ITEM.Bone = 'ValveBiped.Bip01_Spine2'
function ITEM:OnEquip(ply, modifications)
ply:PS_AddClientsideModel(self.ID)
end
function ITEM:OnHolster(ply)
ply:PS_RemoveClientsideModel(self.ID)
end
function ITEM:ModifyClientsideModel(ply, model, pos, ang)
model:SetModelScale(0.8, 0)
pos = pos + (ang:Right() * 5) + (ang:Up() * 6) + (ang:Forward() * 2)
return model, pos, ang
end
Edit: I just noticed my code is using ITEM.Bone, and I know that works, so try that instead of ITEM.Attachment
Try changing the ang variable in the ModifyClientsideModel function
I think the base angle depends on the rotation of the bone, I had to do this for another back item I have:
function ITEM:ModifyClientsideModel(ply, model, pos, ang)
pos = pos + (ang:Forward() * -1.5) + (ang:Right() * 6.1) + (ang:Up() * 0.8)
ang:RotateAroundAxis(ang:Up(), -88)
ang:RotateAroundAxis(ang:Forward(), -90)
return model, pos, ang
end
it’s important that you change the angle after you change the position.
I don’t exactly remember this, since I made my pointshop items about a year ago, but I can see if I still have the old PAC3 data saved, and compare that to some of my pointshop items.
I’ll update this post once I got more info
Here’s a pretty good example, because I’m modifying X, Y, Z, pitch, yaw, roll and scale of this pan hat:
Not sure if it’s different for other bones, but for models attached to the eyes bone, this is the way to go.
Note that some axes are reversed - like, the Y value being -4.4 in pac, but +4.4 in the pointshop function.
Edit:
Yep, seems to be slightly different sometimes (depending on bone maybe?). Here’s the positioning for my jetpack, which is attached to the Spine 2 bone:
(this time, the “yaw” rotation isn’t reversed, as it was for the cookingpot hat)