CapsAdmin

Untitled

Nov 28th, 2012
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.96 KB | None | 0 0
  1. -- how do i make it so a's head follows b's head?
  2.  
  3. local print = epoe.Print
  4.  
  5. SafeRemoveEntity(cs_mdl) local a = ClientsideModel("models/player/combine_super_soldier.mdl") cs_mdl = a
  6. local b = Entity(465)
  7.  
  8. a:SetPos(b:GetPos() + VectorRand() * 50)
  9.  
  10. local function find_bone(ent, str)
  11.     for i = 0, ent:GetBoneCount() do
  12.         local name = ent:GetBoneName(i)
  13.         if name:lower():find(str) then
  14.             return i
  15.         end
  16.     end
  17. end
  18.  
  19. hook.Add("Think", 1, function()    
  20.     local head1 = find_bone(a, "head")
  21.     local head2 = find_bone(b, "head")
  22.    
  23.     -- reset so it doesn't become additive
  24.     a:ManipulateBonePosition(head1, Vector(0,0,0))
  25.     a:ManipulateBoneAngles(head1, Angle(0,0,0))
  26.    
  27.     -- ???????????????????
  28.     local pos1, ang1 = a:GetBonePosition(a:GetBoneParent(head1))
  29.     local pos2, ang2 = b:GetBonePosition(head2)
  30.     local pos, ang = WorldToLocal(pos1, ang1, pos2, ang2)
  31.     -- ~??????????????????
  32.    
  33.     a:ManipulateBoneAngles(head1, ang)
  34.     a:ManipulateBonePosition(head1, pos)
  35. end)
Advertisement
Add Comment
Please, Sign In to add comment