So I made this script and it does work to a certain degree. The goal is to spin around an object and rise straight up still facing the nub of the circle. It is really blocky thought and not smooth. When the camera interpolates, it does not keep it's focus on the nub but rather the focus moves right with the camera as it interpolates.
Essentially it's really simple. It creates the position around the origin. Rises straight up. Finds the angle around the circle. Pushes the position to the circumference of the circle. Finds the nub of the circle at that height. Interpolate.
--module script
function bod.SpinRise(cam, rise, origin, radius, wai) local spin = 1440/rise local ti = rise/wai for i = 1,rise do local cf = (origin * CFrame.new(0,i,0)) * CFrame.Angles(0,math.rad(spin*i),0) * CFrame.new(0,0,-radius) local look = origin * CFrame.new(0,i,0) cam:Interpolate(cf,look,ti) wait(ti) end end
--Local script
local camlib = require(game.Workspace.CameraLibrary) local cam = game.Workspace.CurrentCamera local orig = CFrame.new(0,0,0) cam.CameraType = "Scriptable" camlib.SpinRise(cam,100,orig,50,60)
It does work but it's a very choppy. What can I do to make it smooth?
Right, this is what I got. Seems to work in similar fashion, but it might not be the exact same behaviour, as it was hard to figure out all things that you were doing there + I don't really like the roblox's interpolate method in this case. Well right, this is as smooth as it gets:
function bod.SpinRise(cam, rise, origin, radius, wai) local spin = 1440/rise local i = 0 local lastTick = tick() while i<rise do rs.RenderStepped:wait() local dt = tick()-lastTick i = i+(rise/wai)*dt local cf = CFrame.new(origin.p + Vector3.new(math.cos(math.rad(i*spin)), 0, math.sin(math.rad(i*spin)))*radius + Vector3.new(0, i, 0), origin.p + Vector3.new(0,i,0)) cam.CoordinateFrame = cf lastTick = tick() end end