I’m attempting to achieve a studio-like camera system.
Using bodyForces the camera will slow down to a complete stop rather then instantly stopping, while this may be a cool effect it really wont work with what I want to use it for.
Here is what it currently looks like…
https://gfycat.com/LastAromaticCurlew.gif
Everything is wonderful expect you easily see the sliding that it has using a bodyForce. Would it be possible to make something that instantly stops the camera? I was thinking about deleting the bodyForce and then remaking it but I wasn’t sure if that would screw up the other directions as well.
Here is my current code
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Workspace = game:GetService("Workspace")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")
local CurrentCamera = Workspace.CurrentCamera
local Objects = ReplicatedStorage:WaitForChild("Objects")
local Camera = Objects:WaitForChild("Camera")
Camera = Camera:Clone()
Camera.Parent = Workspace
local BodyForce = Camera:WaitForChild("BodyForce")
local BodyGyro = Camera:WaitForChild("BodyGyro")
local BodyPosition = Camera:WaitForChild("BodyPosition")
local Position = Vector3.new(0,30,0)
local Direction = Vector3.new(0,0,0)
UserInputService.InputEnded:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
local keyPressed = input.KeyCode
if keyPressed == Enum.KeyCode.W then
Direction = Direction + Vector3.new(0, 0, -Direction.Z)
elseif keyPressed == Enum.KeyCode.S then
Direction = Direction + Vector3.new(0, 0, -Direction.Z)
elseif keyPressed == Enum.KeyCode.D then
Direction = Direction + Vector3.new(-Direction.X, 0, 0)
elseif keyPressed == Enum.KeyCode.A then
Direction = Direction + Vector3.new(-Direction.X, 0, 0)
elseif keyPressed == Enum.KeyCode.Q then
Direction = Direction + Vector3.new(0, -Direction.Y, 0)
elseif keyPressed == Enum.KeyCode.E then
Direction = Direction + Vector3.new(0, -Direction.Y, 0)
end
end
end)
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.Keyboard then
local keyPressed = input.KeyCode
if keyPressed == Enum.KeyCode.W then
Direction = Direction + Vector3.new(0, 0, -150)
elseif keyPressed == Enum.KeyCode.S then
Direction = Direction + Vector3.new(0, 0, 150)
elseif keyPressed == Enum.KeyCode.D then
Direction = Direction + Vector3.new(150, 0, 0)
elseif keyPressed == Enum.KeyCode.A then
Direction = Direction + Vector3.new(-150, 0, 0)
elseif keyPressed == Enum.KeyCode.Q then
Direction = Direction + Vector3.new(0, -150, 0)
elseif keyPressed == Enum.KeyCode.E then
Direction = Direction + Vector3.new(0, 150, 0)
end
end
end)
RunService.RenderStepped:connect(function()
CurrentCamera.CFrame = Camera.CFrame
BodyPosition.Position = Position
if Direction then
BodyForce.Force = BodyForce.Force + Direction
end
end)
Here is my Camera Object in the explorer.