Alternatives to ENT.Fire("SetParentAttachment") and overriding derma skin?

First… What are the alternatives to


self:Fire("SetParentAttachment", "bone_name")

Because you cannot adjust entities angle/vector when used that. I guess i could just set its reset its pos on every tick. But its extremely hacky.
Second… How can i override my derma skin. Tried this from wiki:


function GM:ForceDermaSkin() return "skin_name" end
--Also tried this:
hook.Add("ForceDermaSkin", "DermaForced", function() return "skin_name" end)

Used on client… Ofcourse but it doesn’t seem to work.

Also… Closing my other thread… Real smart garry -.- You know… Since i dont need any help or anything, and i dont have to create a second thread…

You created a second threadd cause the other one was closed ?!?!? REAL SMART ! if it was closed it’s cause there was a reason :S

[editline]01:56PM[/editline]

This would be better off in the newbie questions section …

[editline]01:57PM[/editline]

  1.   **[Entity.SetParent
    

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.SetParent)**


(User was banned for this post ("Backseat moderation (don't be a dick)" - mahalis))

It was closed because the title was slightly off… And im trying to attach to a bone… as shown above… I cant ENT.SetParent() to a bone… -.-

you can somehow, i did it for the hat system in my lobby

[editline]02:07PM[/editline]

**[Entity.SetAttachment

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.SetAttachment)**

He is trying to parent to a bone, not to an attachment. You would need to use **[Entity.GetBonePosition

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Entity.GetBonePosition)** and set the position every frame.

Positioning on every tick is REALLY hacky. I’d be happy if i could attach an entity to eyes attachment and be able to adjust angle/vector.
Also tried these:


self:SetParent(own:GetAttachment(own:LookupAttachment("eyes"))) -- as[Ningaglio](http://www.facepunch.com/member.php?u=202456) stated..
self:SetParent(own:LookupBone("ValveBiped.Bip01_Head1")) -- as[Ningaglio](http://www.facepunch.com/member.php?u=202456) stated..
self:Fire("SetParentAttachment", "eyes") -- thought it wouldn't work..
constraint.Weld(self, own, 10, 0, 100, 0) -- Heck.. even tried welding it..

Non of them seam to work.

Not really. You could just parent it to the player serverside for it to have a rough idea of the entity’s position, and set the position just before you draw it clientside.
[lua]
– Clientside.

function ENT:Initialize()
self.Owner = Entity(1);

self.BoneIndex = self.Owner:LookupBone("ValveBiped.Bip01_Head1");

end

function ENT:Draw()
self:SetPos(self.Owner:GetBonePosition(self.BoneIndex));
self:DrawModel();
end[/lua]
Or something similiar.

Position it before drawn, smart. All i did was set its pos on the think hook. Anyway used this:


self:SetAngles(self:GetOwner():GetAttachment(self:GetOwner():LookupAttachment("eyes")).Ang)
self:SetPos(self:GetOwner():GetAttachment(self:GetOwner():LookupAttachment("eyes")).Pos)

I really want to use this


self:SetPos(self:GetOwner():GetBonePosition(self:GetOwner():LookupBone("ValveBiped.Bip01_Head1")))

since this would give far greater compatibility with different models, but i dont know if there is any way to get bones angle.

Oops. I forgot that GetBonePosition actually returns both the position and angles.
[lua]-- Clientside.

function ENT:Initialize()
self.Owner = Entity(1);

self.BoneIndex = self.Owner:LookupBone("ValveBiped.Bip01_Head1");

end

function ENT:Draw()
local pos, ang = self.Owner:GetBonePosition(self.BoneIndex);

self:SetPos(pos);
self:SetAngles(ang);

self:DrawModel();

end[/lua]

Oh, thats cool, thanks for the help :slight_smile:

And really, start posting in the Newbie Questions section. Keeping things organized y’know.


(User was banned for this post ("Backseat moderation" - mahalis))

Yeah :confused: sorry bout that.

I said that in my first post, but i won’t go back over it.

Also , you cant set the pos of an entity client side, so you would need to use a hook other than the Draw one … maybe tick, think or something else

Yes, you can.

Even if you couldn’t, you could use SetRenderOrigin and SetRenderAngles.

Just use “SetParentAttachmentMaintainOffset” instead. Works the same as “SetParentAttachment”, except the entity you’re attaching will keep its relative position to the target attachment of the entity you’re attaching it to.

Works perfectly, thanks.

Also. Guys i’ve another problem.
When i set Vector/Angle in such order:


self:SetAngles(own:GetAttachment(own:LookupAttachment("eyes")).Ang)
self:SetPos(own:GetAttachment(own:LookupAttachment("eyes")).Pos)

the angle gets set only 80% of the time and when i switch the order the angle gets set perfectly, so does the vector, but when i try to offset it (Example: + self:GetForward()-1.85) the entity doesnt obey the forward/up/right commands it goes like this example: if GetForward() -1 then it goes to the right and back, if +1 it goes up and left - just an example. It makes it nearly impossible to offset correctly. Why is this happening?

Are you an alt of chad mobile?

I am also having the issue with the derma skin forcing. What’s going on with it?

I don’t think he is, because I knew Ningaglio years ago. He was an admin on a GMod server, and a really bad one at that.
The reason I say I don’t think he’s a Chad Mobile alt is because they seem to have different writing/posting styles.

Anyway, enough pointless ranting about him, back on topic again

This thread is good for me, I’ve also had problems trying to parent stuff to player bones. Thanks whoever said about setting position in the Draw hook, I never thought about doing that.

Use silverlans suggestion instead, first parent to the entity, then do as silver said. Works allot better. Example:


 self:SetParent(own) self:Fire("SetParentAttachmentMaintainOffset", "eyes")