• Change angle of bones.
    12 replies, posted
Hi, i have an turret with an x axis and an z axis. I would like to change the angle of the z angle. I already tried ent:SetBonePosition() but its not being called... ragdoll:AddCallback("BuildBonePositions", function() print("called") end) ~ result non (tried it server and clientside) ent.BuildBonePositions = function( self, NumBones, NumPhysBones ) ~ Same What could i do wrong? Are there any other ways of doing it?
Post the full code you tried. You should be using AddCallback with BuildBonePositions clientside
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/ManipulateBoneAngles]Entity:ManipulateBoneAngles[/url] [code] -- Example player.GetByID(1):ManipulateBoneAngles( 6, Angle(0,45,0) ) -- Turns the first players head 45 degrees downwards. [/code]
code_gs BuildBonePositions got deleted on wiki.garrysmod.com 0_o (yesterday it was there) Seem´s like it got removed, would explain why it didnt worked anyway. Thiefdroid Thanks :3 Dont know why i didnt found it >.< [editline]27th July 2017[/editline] hm, doesnt work on my model :< Could someone bring this to work? >.< Or is it impossible? *cry* [url]http://www.mediafire.com/file/65447si10m6w0l7/help.zip[/url] I used this [CODE] concommand.Add( "manipulateang", function( ply, cmd, args ) local target=ply:GetEyeTrace().Entity local bones = target:GetPhysicsObjectCount() print("Target:") print(target) for bone = 1, bones-1 do target:ManipulateBoneAngles( bone, Angle(0,20,-45) ) print("manipulated "..bone) end end ) [/CODE] It finds 2 bones on my model.
No, it didn't: [url]https://wiki.garrysmod.com/page/Entity_Callbacks[/url] Post your code, I can't help without seeing what you tried.
[CODE] if SERVER then util.AddNetworkString("change_bone") ent = FindMetaTable("Entity") function ent:SetBonePos(bone,vec,ang) net.Start("change_bone") net.WriteEntity(self) net.WriteString(bone) if vec and !(vec==Vector(0,0,0)) then net.WriteVector(vec) end if ang and !(ang==Angle(0,0,0)) then net.WriteAngle(ang) end local filter = RecipientFilter() filter:AddAllPlayers() net.Send(filter) end end if CLIENT then net.Receive( "change_bone", function(len) local ent = net.ReadEntity() local bone = ent:LookupBone(net.ReadString()) local ov,oa = ent:GetBonePosition(bone) local vec = net.ReadVector() or ov local ang = net.ReadAngle() or oa print("overwrite") print("bone:"..bone) ent.BuildBonePositions = function( self, NumBones, NumPhysBones ) print("Build Bone") end ent:AddCallback("BuildBonePositions",function() print("Build Bone") end) end) end [/CODE] [CODE] concommand.Add( "justatest", function( ply, cmd, args ) local target=ply:GetEyeTrace().Entity target:SetBonePos("z_axis") end ) [/CODE] What it prints out: overwrite bone:1
That's not how you should be doing it -- don't set the bone position serverside. Instead, have a specific callback function that adds itself in an OnEntityCreated hook clientside for your specific entity. [editline]27th July 2017[/editline] Also, in the future, you don't have to use a RecipientFilter anymore for networking.
Could you give me a little example please? I dont really know what you mean. I thought doing addcallback on client is enough 0_o
Is your turret a custom entity?
No, should I make ohne of it?
I think you should -- depends on the application really, but it will make targeting the callback much more specific.
Mh ok, but how can i make an sent ragdoll? Gonna make the night threw if i figure it out. So when i got it how can i do the buildbone callback the right way ? :s: Does a ent even need to be an ragdoll for manipulating it Bons?
Found some interesting functions :) [url]http://wiki.garrysmod.com/page/Entity/SetRagdollBuildFunction[/url] [url]http://wiki.garrysmod.com/page/Entity/SetRagdollAng[/url] [url]http://wiki.garrysmod.com/page/Entity/SetRagdollPos[/url] Working now. Thx for the help ^^
Sorry, you need to Log In to post a reply to this thread.