Python1320

eekbones

Nov 7th, 2011
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.77 KB | None | 0 0
  1. local trace=easylua.FindEntity'Pyth':GetEyeTraceNoCursor()
  2. local bot=easylua.FindEntity'Bot02'
  3. local dist=math.huge
  4. local boneid=-1
  5. local pos=trace.HitPos
  6. for i=0,bot:GetBoneCount()-1 do
  7.     local a=bot:GetBonePosition(i)
  8.     local newdist=a:Distance(pos)
  9.     if newdist < dist then
  10.         dist=newdist
  11.         boneid=i
  12.     end
  13. end
  14. local bpos,bang=bot:GetBonePosition(boneid)
  15. local pos2,ang2=WorldToLocal(pos,(trace.StartPos-trace.HitPos):Angle(),bpos,bang)
  16. print(pos2,ang2)
  17.  
  18. if SERVER then return end
  19.  
  20. if a and IsValid(a) then a:Remove() end
  21. a=ClientsideModel"models/props_trainstation/trainstation_post001.mdl"
  22. hook.Add('Think',1,function()
  23.     local bpos,bang=bot:GetBonePosition(boneid)
  24.    
  25.     local pos3,ang3=LocalToWorld(pos2,ang2,bpos,bang)
  26.     a:SetPos(pos3)
  27.    
  28.     a:SetAngles(ang3)
  29. end)
  30.  
Advertisement
Add Comment
Please, Sign In to add comment