I’m making a First person shooter game, and it has a killcam where when you die, you have your camera focused on the ennemy that killed you.
The script down below should set camera min and max distance at a higher value than 0.5, which is the First Person view.
The LocalScript for the killcam works fine. However, the camera will stay on the First Person view if the player doesn’t scroll with the mouse, or swipe on mobile.
local cam = game.Workspace.CurrentCamera
local plr = game.Players.LocalPlayer or game.Players.PlayerAdded:Wait()
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
hum.Died:Connect(function()
local kil = char.Humanoid:FindFirstChild("creator")
if kil.Value then
wait(2)
cam.CameraSubject = kilChar.Humanoid
plr.CameraMinZoomDistance = 10
plr.CameraMaxZoomDistance = 10
wait(3)
plr.CameraMinZoomDistance = 0.5
plr.CameraMaxZoomDistance = 0.5
cam.CameraSubject = hum
end
end)
Is there a way to set the Camera at the given distance, without needing the player to scroll ?
Thank you ! (and sorry for my mediocre english, if you didn’t understand something tell me)
If you want to create an effect like in Arsenal when a player dies, and the camera is then focused on the person who killed them in a third person view, then I don’t think using these two properties of the camera is the way to go.
These properties won’t actually change the zoom distance, just how far in or out a player can zoom. I would recommend experimenting with the CFrame of the camera instead, as well as setting the camera’s subject to the killer.
Adding on to my reply. One way to do this off the top of my head is setting the camera’s CFrame to the killer’s HumanoidRootPart, then adding an offset to it so the camera isn’t stuck inside the part.
For some reason it sounds for me you want a battlefield 1 like killcam (can’t upload part of a video - error, search it yourself)
If your camera goes from first person to third person, I think you want to change Camera.CameraType to Scriptable and then just change its CFrame every frame, something like
I am not using camera subject as you can see, i think it’s useless when you can control the whole camera with cframes (if you understand what are these, of course)