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.

https://www.google.com.au/imgres?imgurl=https://i.ytimg.com/vi/05Ci5VYELOk/maxresdefault.jpg&imgrefurl=https://www.youtube.com/watch?v%3D05Ci5VYELOk&h=720&w=1280&tbnid=lqDqm9VFSe3hkM:&docid=be8sQF8fw-jcWM&hl=en-GB&ei=8WWgVp-hNMuv0gTIqJ_ADg&tbm=isch&ved=0ahUKEwjf3bbcj7rKAhXLl5QKHUjUB-gQMwgcKAAwAA

^^^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)
	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

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
end

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:

https://dl.dropboxusercontent.com/u/50211087/gmod/PAC3_to_Pointshop.png

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)

https://dl.dropboxusercontent.com/u/50211087/gmod/PAC3_to_Pointshop_2.png