How to make camera move roundly?

local RunService = game:GetService("RunService")
local CurrentCamera = workspace.CurrentCamera

local CameraPart = workspace.World.Structures.Miscellaneous.IntroCamera:WaitForChild("CameraPart")

local ROTATION_SPEED = 0.05

CurrentCamera.CameraSubject = CameraPart
CurrentCamera.CFrame = CameraPart.CFrame
CurrentCamera.CameraType = Enum.CameraType.Scriptable

RunService.RenderStepped:Connect(function(deltaTime)
    CurrentCamera.CFrame = CFrame.Angles(0, ROTATION_SPEED * deltaTime, 0)
end)

This code moves the camera up slightly.
How can I fix this?

1 Like

I have no idea what you mean by roundly, you mean in a circle? or smoothly around a corner?

If that’s it, look into Bézier curves. They are probably what you’re looking for.

But why that doesn’t work is your setting the camera to a position, not adding onto the existing one, heres a fix:

 CurrentCamera.CFrame *= CFrame.Angles(0, ROTATION_SPEED * deltaTime, 0)
1 Like

ROTATION_SPEED * deltaTime is always going to be about the same value. The deltaTime parameter is the time since the last render step, not total elapsed game time. You need to either track the total elapsed time, or you need to move the camera incrementally by multiplying its current CFrame by CFrame.Angles(0, ROTATION_SPEED * deltaTime, 0) instead of setting it to that value.

That said, this will just make your camera turn in place. It’s not clear if that’s what you want, or if what you really want is for it to orbit the CameraSubject and remain pointed at it (which is a totally different calculation).

3 Likes

This was what I meant.

try a different axis, might fix it

What’s the issue, rotates “roundly” ig.

Im guessing you want it to orbit around something? You will need to use CameraSubject for that.

So I used CameraSubject but the camera slightly moves upward like this vid.

I still don’t get what you’re trying to achieve? A cutscene, an orbital camera? You barely provided any information.

My goal is make cutscene like this.


But my code is working like this. (I don’t want the camera slightly move upward.)

Test this out:

local RunService = game:GetService("RunService")
local CurrentCamera = workspace.CurrentCamera

local CameraPart = workspace.World.Structures.Miscellaneous.IntroCamera:WaitForChild("CameraPart")

local ROTATION_SPEED = 0.05

CurrentCamera.CameraType = Enum.CameraType.Scriptable
CurrentCamera.CFrame = CameraPart.CFrame

RunService.RenderStepped:Connect(function(deltaTime)
	CurrentCamera.CFrame *= CFrame.Angles(0, ROTATION_SPEED * deltaTime, 0)
end)

This code works in normal situation.
But my Camera Part is tilted downward.
When I run this code with the Camera Part is tilted, the camera moves slightly upward, just like in the second video.

So, I was testing things out in studio and got a working version, let me know if this works for you.

local RunService = game:GetService("RunService")
local CurrentCamera = workspace.CurrentCamera
local CameraPart = workspace:WaitForChild("CameraPart")
local ROTATION_SPEED = 0.05

local angle = 0
local startCFrame = CameraPart.CFrame
local initialTilt = CFrame.new(Vector3.new(0,0,0), startCFrame.LookVector)

CurrentCamera.CameraType = Enum.CameraType.Scriptable

RunService.RenderStepped:Connect(function(deltaTime)
	angle = angle + (ROTATION_SPEED * deltaTime)

	local newCFrame = CFrame.new(startCFrame.Position) * 
		CFrame.Angles(0, angle, 0) * 
		CFrame.Angles(initialTilt:ToEulerAnglesYXZ())

	CurrentCamera.CFrame = newCFrame
end)
1 Like

Wow It is working!
Thanks a lot!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.