Advertisement
StefanBashkir

Untitled

May 21st, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.76 KB | None | 0 0
  1. local a,b,c = workspace.A, workspace.B, workspace.C
  2. local distanceFactor = 1 -- decimal = smaller distance away, whole numbers > 1 = more distance away
  3.  
  4. -- a,b are outer walls. c is the camera block
  5. -- For use in an actual game, just find out which two players are closest to the edge of the map.
  6. -- Replace a and b with their positions.
  7.  
  8. while wait() do
  9.     local aPos,bPos,cPos = a.Position, b.Position, c.Position -- If you do what the above comments suggest, remove .Position from a and b
  10.     local connectionLine = (bPos - aPos)
  11.     local distance = connectionLine.magnitude
  12.     local midPoint = aPos:lerp(bPos, 1/2)
  13.     local perpendicularLine = Vector3.new(connectionLine.Z, 0, -connectionLine.X).unit
  14.    
  15.     c.Position = midPoint + (perpendicularLine*distance*distanceFactor)
  16. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement