Hello there. This post is to showcase and open source a concept I have had for months but have just made.
Here is a short showcase video:https://youtu.be/VBSkWhztPXQ. I was testing it on a alt.
To use it you must do two simple things:
- Download the updated player module and put it in StarterPlayerScripts.
- Add this local script to StarterPlayerScripts:
local camPart = Instance.new("Part")
camPart.Size = Vector3.new(1,1,1)
camPart.CanCollide = false
camPart.Anchored = true
camPart.Transparency = 1
camPart.Name = "CurrrentCameraPart"
camPart.Parent = game.Workspace
local camRig = Instance.new("Part")
camRig.Size = Vector3.new(1,1,1)
camRig.CanCollide = false
camRig.Parent = game.Workspace
camRig.Transparency = 1
local RUS = game:GetService("RunService")
local bv = Instance.new("BodyVelocity")
bv.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bv.Velocity = (camPart.Position - workspace.CurrentCamera.CFrame.p).Unit * 10
local gy = Instance.new("BodyGyro")
gy.MaxTorque = Vector3.new(30000, 30000, 30000)
workspace.CurrentCamera.CameraType = Enum.CameraType.Follow
bv.Parent = camRig
gy.Parent = camRig
RUS.Heartbeat:Connect(function()
local char =game.Players.LocalPlayer.Character
if not char then
return
end
local head = game.Players.LocalPlayer.Character:FindFirstChild("Head") :: BasePart
if not head then
return
end
workspace.CurrentCamera.CFrame = camRig.CFrame
-- find the distance beetween the camera and the camPart
local distance = (workspace.CurrentCamera.CFrame.p - camPart.Position).Magnitude
-- if it's too far away, move the rig closer to the camera
local newDistance = math.min(distance, 50)
local NormDistance = (distance / 50)
bv.Velocity = (camPart.Position- workspace.CurrentCamera.CFrame.p).Unit * (NormDistance * 100)
gy.CFrame = CFrame.lookAt(camRig.Position, head.Position)
end)
I am not saying this code uses the best practices I am just demonstrating and open-sourcing a concept.
This has not been tested for vehicles so I would assume it would not work for them although anybody with moderate scripting knowledge should be able to reverse engineer and make it work with vehicles and even possibly comment a improved copy. It also does not work for first person and you should set zoom constraints.
Here is the updated module:
PlayerModule.rbxm (127.9 KB)
Thanks for reading. I wish you luck with using this.