• SetParentAttachmentMaintainOffset trouble
    1 replies, posted
Hello guys! Trying to attach entity to player. I want to make to the attack, the weapon was shifted to his other hand. The problem is that the attachment is working correctly only 80% of cases, in the rest of the model 20 is attached at the wrong angle and position. [B]Code:[/B] [CODE]function SWEP:Deploy() self:SetHoldType( "passive" ) local ply = self.Owner ply:SetLuaAnimation("Bala_stance") timer.Simple(0.35, function() self.balala = ents.Create("prop_dynamic") self.balala:SetParent(self.Owner) self.balala:SetModel( "models/balalayka.mdl" ) self.balala:SetLocalPos( Vector( -7, 0, 2 ) ) self.balala:SetLocalAngles( Angle(160,75,75) ) self.balala:Fire("SetParentAttachmentMaintainOffset", "Anim_Attachment_LH", 0.01 ) self.balala:SetCollisionGroup( 11 ) self.balala:Spawn() self.balala:Activate() ply:DeleteOnRemove(self.balala) end) end[/CODE] And attack function [CODE]function SWEP:PrimaryAttack() if self.Owner:Crouching() then return end if self.Owner:KeyDown(IN_USE) and self.Owner:GetVelocity():Length() < 5 then if not self.Owner then return end local ply = self.Owner if not IsValid(ply) then return end ply:SetNetworkedBool("Block",false) self:SetHoldType( "melee" ) self:SetNoDraw(false) self.balala:SetLocalPos( Vector( 0, 10, 9 ) ) self.balala:SetLocalAngles( Angle(0,0,75) ) self.balala:Fire("SetParentAttachmentMaintainOffset", "Anim_Attachment_RH", 0.01 ) ply:ChatPrint( "Uppercut" ) ply:SetAnimation( PLAYER_ATTACK1 ) self:EmitSound( "bare/swing"..math.random(1,9)..".wav" ) timer.Simple(1.2, function() self:SetHoldType( "passive" ) self.balala:SetLocalPos( Vector( -7, 0, 2 ) ) self.balala:SetLocalAngles( Angle(160,75,75) ) self.balala:Fire("SetParentAttachmentMaintainOffset", "Anim_Attachment_LH", 0.01 ) -- self:Faceblood() -- self:HeadShake() -- self:PushWeak() end) timer.Simple(0.3, function() -- self:Faceblood() self:HeadShake() self:Knockout() -- self:PushWeak() end) self:SetNextMeleeAttack( CurTime() + 0.2 ) self:SetNextPrimaryFire( CurTime() + 1.9 ) self:SetNextSecondaryFire( CurTime() + 1.9 ) end end[/CODE] [editline]6th May 2015[/editline] "SetParentAttachment" Works perfect, but i cant set angle\vector with this.
I figured it out. If someone interesting how: First do "SetParentAttachment" then a simple timer which already specifies the local angle and position.It works perfectly with the dynamic prop. I found what this is the best option for me. If you have more cool method, please, wright this.
Sorry, you need to Log In to post a reply to this thread.