how to make a front flip effect on the camera? the character flips and how to make the camera flip too?
First, you need to set the camera type to Scriptable
. Then, you should constantly lerp the CFrame of the camera to the character.
how to change the camera and lerp it? i dont have any experience with camera can u demonstrate me?
You can change the camera type to scriptable camera.CameraType = Enum.CameraType.Scriptable
and then lerp the CFrame camera.CFrame = camera.CFrame:Lerp(character.Head.CFrame, 0.1)
and you need to loop it in RenderStepped.
it didnt work, the player moved and the camera didnt
What is your code? You are probably lerping the head’s CFrame.
i used exatcly the one u give me
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = camera.CFrame:Lerp(character.Head.CFrame, 0.1)
I put together this function that makes use of CFraming. This must be run on the Client (In a local script) so make sure to use a RemoteEvent if the server initiates the flip.
The t
in the function is the time it takes for the camera to flip, for example, flipCam(3)
would flip the camera over a 3 second period.
function flipCam(t)
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = game.Players.LocalPlayer.Character.Head
local info1 = TweenInfo.new(t / 2, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0, false, 0)
local info2 = TweenInfo.new( t / 2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
game:GetService('TweenService'):Create(camera, info1, {CFrame = (camera.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(180), 0, 0))}):Play()
task.wait(t / 2)
game:GetService('TweenService'):Create(camera, info2, {CFrame = (camera.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(180), 0, 0))}):Play()
task.wait((t/ 2) + 0.1)
camera.CameraType = Enum.CameraType.Custom
end
it dont work, when the camera reach the maximum down it starts glitching
Can you show me how you implemented it, because it worked perfectly for me.
oh i did it wrong it worked now, thank you so muuch
after fliping, the second time the flip starts going up instead of down,what to do?
Odd, I will experiment and figure out a fix.
the body in first person is shown, and after flipping the first person does not turn the body again and the hair appears, what dont happen usually
I believe I have solved the issue. Try this updated function:
function flipCam(t)
local camera = workspace.CurrentCamera
camera.CameraType = Enum.CameraType.Scriptable
camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
local info1 = TweenInfo.new(t / 2, Enum.EasingStyle.Quad, Enum.EasingDirection.In, 0, false, 0)
local info2 = TweenInfo.new( t / 2, Enum.EasingStyle.Quad, Enum.EasingDirection.Out, 0, false, 0)
game:GetService('TweenService'):Create(camera, info1, {CFrame = (camera.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(180), 0, 0))}):Play()
task.wait(t / 2)
game:GetService('TweenService'):Create(camera, info2, {CFrame = (camera.CFrame * CFrame.fromEulerAnglesXYZ(math.rad(180), 0, 0))}):Play()
task.wait((t/ 2) + 0.1)
camera.CameraType = Enum.CameraType.Custom
end
thx it fixed the 2 problems, but can the camera go with the body while flipping? cuz the camera stay while the body goes
What do you mean by this? You want the camera to flip at the exact same time as the body?
no, when the flip starts the body keep walking but the camera stays in the same position then when the flip finish it teleports back to the player
Ah. This requires a bit more complex programming as the camera has to be moved with the player.
do you have any idea of how to do it? ill try to in the [ wait t/ 2 ] put some loop to put the camera in the player for the same duration