Right attachment/lua

Been using this code;

ITEM.Model = ‘models/maxofs2d/companion_doll.mdl’
ITEM.Attachment = ‘ValveBiped.Bip01_Spine2’

function ITEM:ModifyClientsideModel(ply, model, pos, ang)
model:SetModelScale(1.6, 0)
pos = pos + (ang:Forward() * -2.5)
ang:RotateAroundAxis(ang:Right(), -15)

(not all of it)

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.


^^^What the doll looks like.

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.

Ah okay, thank you. The problem is, is that its not positioning on the back of a player, its going on weird angles.

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)

function ITEM:OnHolster(ply)

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

Edit: I just noticed my code is using ITEM.Bone, and I know that works, so try that instead of ITEM.Attachment

Yeah for some reason, it turns it on a right side angle, weird. I’ll just use PAC 3 though. Thank you however.

EDIT: Could someone show me an example of porting the pac 3 settings to lua? e.g. any new command lines etc

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

it’s important that you change the angle after you change the position.

Yes!, thank you!

Glad I could help!

Oh, I missed your post edit earlier:

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.

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)