Skip to content
This repository was archived by the owner on Jun 11, 2020. It is now read-only.
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<roblox xmlns:xmime="http://www.w3.org/2005/05/xmlmime" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://www.roblox.com/roblox.xsd" version="4">
<External>null</External>
<External>nil</External>
<Item class="ModuleScript" referent="RBX5744EB97A6D34E5AA94E31CE07E5D09D">
<Item class="ModuleScript" referent="RBX100DF6F24BA54212B68F05C9E17C8284">
<Properties>
<Content name="LinkedSource"><null></null></Content>
<string name="Name">ClassicCamera</string>
Expand Down Expand Up @@ -36,11 +36,6 @@ end
local function CreateClassicCamera()
local module = RootCameraCreator()

local tweenAcceleration = math.rad(220)
local tweenSpeed = math.rad(0)
local tweenMaxSpeed = math.rad(250)
local timeBeforeAutoRotate = 2

local lastThumbstickRotate = nil
local numOfSeconds = 0.7
local currentSpeed = 0
Expand Down Expand Up @@ -72,30 +67,19 @@ local function CreateClassicCamera()
-- Cap out the delta to 0.5 so we don't get some crazy things when we re-resume from
local delta = math.min(0.5, now - lastUpdate)
local angle = 0
if not (isInVehicle or isOnASkateboard) then
angle = angle + (self.TurningLeft and -120 or 0)
angle = angle + (self.TurningRight and 120 or 0)
end
angle = angle + (self.TurningLeft and -120 or 0)
angle = angle + (self.TurningRight and 120 or 0)

local gamepadRotation = self:UpdateGamepad()
if gamepadRotation ~= Vector2.new(0,0) then
userPanningTheCamera = true
self.RotateInput = self.RotateInput + gamepadRotation
end

if angle ~= 0 then
userPanningTheCamera = true
self.RotateInput = self.RotateInput + Vector2.new(math.rad(angle * delta), 0)
end
end

-- Reset tween speed if user is panning
if userPanningTheCamera then
tweenSpeed = 0
module.LastUserPanCamera = tick()
end

local userRecentlyPannedCamera = now - module.LastUserPanCamera < timeBeforeAutoRotate
local subjectPosition = self:GetSubjectPosition()

if subjectPosition and player and camera then
Expand All @@ -112,36 +96,19 @@ local function CreateClassicCamera()
if IsFiniteVector3(offset) then
subjectPosition = subjectPosition + offset
end
else
if self.LastCameraTransform and not userPanningTheCamera then
local isInFirstPerson = self:IsInFirstPerson()
if (isInVehicle or isOnASkateboard) and lastUpdate and humanoid and humanoid.Torso then
if isInFirstPerson then
if self.LastSubjectCFrame and (isInVehicle or isOnASkateboard) and cameraSubject:IsA('BasePart') then
local y = -findAngleBetweenXZVectors(self.LastSubjectCFrame.lookVector, cameraSubject.CFrame.lookVector)
if IsFinite(y) then
self.RotateInput = self.RotateInput + Vector2.new(y, 0)
end
tweenSpeed = 0
end
elseif not userRecentlyPannedCamera then
local forwardVector = humanoid.Torso.CFrame.lookVector
if isOnASkateboard then
forwardVector = cameraSubject.CFrame.lookVector
end
local timeDelta = (now - lastUpdate)

tweenSpeed = clamp(0, tweenMaxSpeed, tweenSpeed + tweenAcceleration * timeDelta)

local percent = clamp(0, 1, tweenSpeed * timeDelta)
if self:IsInFirstPerson() then
percent = 1
end

local y = findAngleBetweenXZVectors(forwardVector, self:GetCameraLook())
if IsFinite(y) and math.abs(y) > 0.0001 then
self.RotateInput = self.RotateInput + Vector2.new(y * percent, 0)
end
end
if (isInVehicle or isOnASkateboard) and lastUpdate and humanoid and humanoid.Torso then
if (isInVehicle or isOnASkateboard) and cameraSubject:IsA('BasePart') then
if self.LastSubjectCFrame then
local y = -findAngleBetweenXZVectors(self.LastSubjectCFrame.lookVector, cameraSubject.CFrame.lookVector)
if IsFinite(y) then
self.RotateInput = self.RotateInput + Vector2.new(y, 0)
end
elseif self.LastCameraTransform then
--this is so that the camera retains its heading when sitting in a vehicle seat
local y = findAngleBetweenXZVectors(self.LastCameraTransform.lookVector, Vector3.new(0,0,-1))
if IsFinite(y) then
self.RotateInput = self.RotateInput + Vector2.new(y, 0)
end
end
end
Expand Down