I’m currently working on a game that is inspired by Doors, and I’m struggling with replicating the camera movement in the game. If you haven’t played Doors before, I’m talking about a slight overshoot, realistic camera bobbing, tilting, and overall smoothness.
I’ve seen a few other posts on here about similar inquiries but none seem to have been answered in enough detail or even answered at all.
Does anybody know of a way I can replicate this effect?
To achieve a smooth camera movement with overshoot, bobbing, tilting, and smoothness, you can use a combination of camera manipulation functions in Roblox.
Here is some sample code that you can modify to achieve the effect you are looking for:
local camera = workspace.CurrentCamera
-- Variables for camera movement
local cameraPosition = camera.CFrame.Position
local cameraVelocity = Vector3.new(0, 0, 0)
local cameraAcceleration = Vector3.new(0, 0, 0)
-- Camera settings
local cameraOvershoot = 1.2
local cameraBobbing = 0.05
local cameraTilting = 0.05
-- Function to move the camera
local function moveCamera(targetPosition)
local deltaPosition = targetPosition - cameraPosition
local distance = deltaPosition.magnitude
local direction = deltaPosition.unit
-- Calculate acceleration
local maxAcceleration = 100
cameraAcceleration = direction * math.min(distance * maxAcceleration, maxAcceleration)
-- Update velocity
cameraVelocity = cameraVelocity + cameraAcceleration * 0.016
-- Calculate overshoot
local overshoot = math.max(1 - cameraVelocity.magnitude / (distance * cameraOvershoot), 0)
-- Update position
cameraPosition = cameraPosition + cameraVelocity * 0.016 * (1 + overshoot)
-- Calculate bobbing and tilting
local bobbing = Vector3.new(
math.sin(workspace.DistributedGameTime * 10) * cameraBobbing,
math.cos(workspace.DistributedGameTime * 10) * cameraBobbing,
0
)
local tilting = Vector3.new(
cameraVelocity.y * cameraTilting,
0,
cameraVelocity.x * -cameraTilting
)
-- Update camera CFrame
camera.CFrame = CFrame.new(cameraPosition + bobbing + tilting, cameraPosition + direction)
end
-- Example usage
while true do
moveCamera(Vector3.new(10, 5, 0))
wait()
end
This code sets up a basic camera movement system with variables for camera position, velocity, and acceleration. It uses camera manipulation functions to calculate overshoot, bobbing, and tilting. You can tweak the camera settings to achieve the desired effect, and you can call the moveCamera() function to move the camera to a target position.
I hope this helps! Let me know if you have any questions or need further assistance.
Thanks ChatGPT! I couldn’t have done this without your help—works like a charm! I love the way that the camera glitches and moves around despite me not moving my mouse at all!
(In
all seriousness if you’re using ChatGPT to reply to devforum posts, I think that’s just pathetic, and based on your replies to other posts I don’t think you should be on the devforum in the first place. Please go find somewhere else to waste peoples’ time and don’t resort to replying to people who actually need help with something to compensate for your lack of a father figure.)
Hello! I have recently been in the works of developing a horror game and have been working on making a similar first person camera that you want. The way I figured it out was looking at this free model and making my own, you can just use the model but I’d recommend trying to learn how he did what he did.
I hope this helps, If you still can’t seem to figure it out I would love to give further support and even open source my personal first person model. Good luck figuring things out!