wait(1) workspace.CurrentCamera.CFrame = CFrame.new(0,0,0) * CFrame.Angles(math.rad(25), 1, 1)
I tried this but it didn't work. What I am trying to create is rotating the camera, like in gta 5 when you're in an airplane and you turn. Does anyone know what I should use to achieve it?
I've been messing around with this for the past half-hour or so, and the only way I can seem to rotate the camera is to use the wait()
method of RenderStepped.
I even tried binding the function to a renderstep, which's priority is OVER that of Roblox's default camera script, but to no avail. This is an extremely weird functionality, and (from what I've found) has no documentation on it.
What I've done in the script below is using a while loop, with function, as to not hault the main thread, and rotate the camera 1 degree every 1/30th of a second (in theory):
rs = game:GetService("RunService") cam = game.Workspace.CurrentCamera rot = 0 spawn(function() while rs.RenderStepped:Wait() do cam.CFrame = cam.CFrame* CFrame.Angles(0, 0, math.rad(rot)) end end) for i=1,360 do wait() rot=rot+1 end
But, what is REALLY confusing, is that, as I said, the function fails to work at all with any delay under that of the current frame time (supposedly 1/60th of a second), though even though :BindToRenderStep()
is the frame-time, it still doesn't work, as shown below:
rs = game:GetService("RunService") cam = game.Workspace.CurrentCamera rs:BindToRenderStep("1", Enum.RenderPriority.Camera.Value+1, function() cam.CoordinateFrame = cam.CoordinateFrame* CFrame.Angles(0, 0, math.rad(90)) end)
If anyone can find out why this is the case, I'd be interesting in knowing!
EDIT: Both scripts work now. Don't use the first one, as creating a new thread is bad. I stupidly set the RenderPriority to Enum.RenderPriority.Camera.Value-1
rather than Enum.RenderPriority.Camera.Value+1
. My bad, lol