Advertisement
Guest User

Roblox 2d camera

a guest
Apr 22nd, 2018
1,254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. local camera = game.Workspace.CurrentCamera
  2. local player = game.Players.LocalPlayer
  3.  
  4. camera.CameraType = Enum.CameraType.Scriptable
  5.  
  6. local targetDistance = 30
  7. local cameraDistance = -30
  8. local cameraDirection = Vector3.new(-1,0,0)
  9.  
  10. local currentTarget = cameraDirection*targetDistance
  11. local currentPosition = cameraDirection*cameraDistance
  12.  
  13. game:GetService("RunService").RenderStepped:connect(function()
  14. local character = player.Character
  15. if character and character:FindFirstChild("Humanoid") and character:FindFirstChild("HumanoidRootPart") then
  16. local torso = character.HumanoidRootPart
  17. camera.Focus = torso.CFrame
  18. if torso:FindFirstChild("FastStart") == nil then
  19. camera.CoordinateFrame = CFrame.new(Vector3.new(torso.Position.X, torso.Position.Y + 10, torso.Position.Z - 20) + currentPosition,
  20. Vector3.new(torso.Position.X, torso.Position.Y, torso.Position.Z - 20) + currentTarget)
  21. else
  22. --Lower camera for fast start
  23. camera.CoordinateFrame = CFrame.new(Vector3.new(torso.Position.X, torso.Position.Y - 15, torso.Position.Z - 20) + currentPosition,
  24. Vector3.new(torso.Position.X, torso.Position.Y - 15, torso.Position.Z - 20) + currentTarget)
  25. end
  26. end
  27. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement