CapsAdmin

Untitled

Feb 28th, 2013
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.55 KB | None | 0 0
  1.     local dir = pos - phys:GetPos() -- direction to the rod
  2.                     local len = dir:Length() / self.dt.length -- normalize the length
  3.                    
  4.                     len = len ^ 20 -- make it so length isn't linear
  5.                     dir:Normalize() -- normalize the dir so we can scale it properly back up
  6.                    
  7.                     -- apply the force offset from the hook
  8.                     phys:ApplyForceOffset(dir * (len * self.dt.length), phys:GetPos() + hook:GetUp() * 50)
  9.                    
  10.                     -- add some damping
  11.                     phys:AddAngleVelocity(phys:GetAngleVelocity() * -0.1)
  12.                     phys:AddVelocity(phys:GetVelocity() * -0.01)
Advertisement
Add Comment
Please, Sign In to add comment