• Right attachment/lua
    7 replies, posted
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. [URL="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"]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[/URL] ^^^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.
[QUOTE=Mornedil;49575355]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.[/QUOTE] Ah okay, thank you. The problem is, is that its not positioning on the back of a player, its going on weird angles.
[QUOTE=RainSnow;49575391]Ah okay, thank you. The problem is, is that its not positioning on the back of a player, its going on weird angles.[/QUOTE] 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: [CODE]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[/CODE] Edit: I just noticed my code is using ITEM.Bone, and I know that works, so try that instead of ITEM.Attachment
[QUOTE=Mornedil;49575438]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: Yeah for some reason, it turns it on a right side angle, weird. I'll just use PAC 3 though. [CODE]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[/CODE] Edit: I just noticed my code is using ITEM.Bone, and I know that works, so try that instead of ITEM.Attachment[/QUOTE] 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
[QUOTE=RainSnow;49575465]Yeah for some reason, it turns it on a right side angle, weird. I'll just use PAC 3 though. Thank you however.[/QUOTE] 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: [CODE]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[/CODE] it's important that you change the angle after you change the position.
[QUOTE=Mornedil;49575517]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: [CODE]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[/CODE] it's important that you change the angle after you change the position.[/QUOTE] Yes!, thank you!
Glad I could help! Oh, I missed your post edit earlier: [QUOTE=RainSnow;49575465]EDIT: Could someone show me an example of porting the pac 3 settings to lua? e.g. any new command lines etc[/QUOTE] 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: [IMG]https://dl.dropboxusercontent.com/u/50211087/gmod/PAC3_to_Pointshop.png[/IMG] 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) [IMG]https://dl.dropboxusercontent.com/u/50211087/gmod/PAC3_to_Pointshop_2.png[/IMG]
Sorry, you need to Log In to post a reply to this thread.