Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- assorted code from two files
- -- ####################################################################################################################################
- -- Relevant bits of the module:
- local function defaultRenderStep()
- print("Default Render Step")
- UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
- -- set visibility for parts
- for pPart, nValue in pairs(tPartVisibility) do
- pPart.LocalTransparencyModifier = nValue
- end
- -- make the character's body move with the camera, and clamp up/down look.
- local firstPart = Camera
- local secondPart = rootPart
- local firstPartCF = firstPart.CFrame --The first part's CFrame
- local firstPartAngleCF = firstPartCF-firstPartCF.p --The first part's CFrame without the position (Or a position of {0,0,0})
- local x, y, z = firstPartAngleCF:ToEulerAnglesYXZ()
- firstPartAngleCF = CFrame.Angles(0, y, 0)
- secondPart.CFrame = firstPartAngleCF + secondPart.CFrame.p --We set the CFrame to the angle of the first part and the position of the second.
- local rX, rY, rZ = Camera.CFrame:ToOrientation()
- local limX = math.clamp(math.deg(rX), -45, 70)
- Camera.CFrame = CFrame.new(Camera.CFrame.p) * CFrame.fromOrientation(math.rad(limX), rY, rZ)
- end
- local function deathRenderStep()
- print("Death Render Step")
- UIS.MouseBehavior = Enum.MouseBehavior.Default
- -- set visibility for parts
- for pPart, nValue in pairs(tPartVisibility) do
- pPart.LocalTransparencyModifier = nValue
- end
- -- make the character's body move with the camera, and clamp up/down look.
- local firstPart = rootPart.Parent.Head
- local secondPart = Camera
- local firstPartCF = firstPart.CFrame --The first part's CFrame
- local firstPartAngleCF = firstPartCF-firstPartCF.p --The first part's CFrame without the position (Or a position of {0,0,0})
- local x, y, z = firstPartAngleCF:ToEulerAnglesYXZ()
- firstPartAngleCF = CFrame.Angles(0, y, 0)
- secondPart.CFrame = firstPartAngleCF + secondPart.CFrame.p --We set the CFrame to the angle of the first part and the position of the second.
- end
- function module.DeathCamera()
- print("DEATH CAMERA CALLED!")
- Camera.CameraType = Enum.CameraType.Fixed
- Player.CameraMode = Enum.CameraMode.LockFirstPerson
- Camera.CameraSubject = Player.Character.Head
- RunService:UnbindFromRenderStep("CustomCameraControl")
- RunService:UnbindFromRenderStep("DefaultCameraControl")
- RunService:UnbindFromRenderStep("DeathCameraControl")
- RunService:BindToRenderStep("DeathCameraControl", Enum.RenderPriority.Camera.Value - 5, deathRenderStep)
- print("DEATH CAMERA DONE!")
- end
- -- reset the camera to the default camera.
- function module.DefaultCamera()
- print("DEFAULT CAMERA CALLED!")
- Camera.CameraType = Enum.CameraType.Attach
- Player.CameraMode = Enum.CameraMode.LockFirstPerson
- Camera.CameraSubject = Player.Character.Head
- RunService:UnbindFromRenderStep("CustomCameraControl")
- RunService:UnbindFromRenderStep("DefaultCameraControl")
- RunService:UnbindFromRenderStep("DeathCameraControl")
- RunService:BindToRenderStep("DefaultCameraControl", Enum.RenderPriority.Camera.Value - 5, defaultRenderStep)
- print("DEFAULT CAMERA DONE!")
- end
- -- ####################################################################################################################################
- -- the other file
- local function initCharacter(Character) -- Connect()ed to event: player.CharacterAdded
- bInited = true
- Controls.updateCharacter(Character) -- ensure the controller has the right character
- Controls.DefaultCamera() -- set the default camera
- --
- -- add things to PartVisibility, not relevant
- --
- Character.Humanoid.Died:Connect(function()
- warn("Death!")
- Controls.DeathCamera()
- end)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement