✓ Accepted answer
There are three main methods that I use to keep the camera from zooming in/out.
(1.) (requires 0 scripting), you can change the properties CameraMaxZoomDistance and CameraMinZoomDistance inside StarterPlayer to the same value. (i.e. if you wanted a player's camera to only be able to stay 5 studs away you would change both values to 5)
(2.) (requires some scripting in a local script), This method will basically fix the camera to remain at a certain point in 3d space. Lets say I wanted the camera to always remain at point (0, 10, 0):
local wte = wait;
local new_cfr = CFrame.new;
local cam = game.Workspace.CurrentCamera;
spawn(function()
while wte() do
cam.CoordinateFrame = new_cfr(0, 10, 0);
end
end)
(3.) (requires a lot of scripting in a local script) This method essentially 're-programs' the client camera to remain at a certain distance from the player according to their 'orientation'. You will have to override the standard CameraScript to get this method to completely work. You can do so by inserting a local script into StarterPlayer->StarterPlayerScripts and naming it CameraScript. Now Here is a basic example of code that will manage your client camera to remain a certain amount of studs away from your player and continuously face where your place is facing:
local wte = wait;
local new_cfr = CFrame.new;
local cam = game.Workspace.CurrentCamera;
local rot = CFrame.fromEulerAnglesXYZ;
local pcl = pcall;
local plrs = game:GetService("Players");
spawn(function()
while wte() do
pcl(function()
local char = plrs.LocalPlayer.Character;
local trs = char.Torso;
cam.CoordinateFrame = trs.CFrame - (trs.CFrame.lookVector * 5) +
(trs.CFrame.upVector * 5);
cam.CoordinateFrame = cam.CoordinateFrame * rot(-0.15, 0, 0);
cam.CoordinateFrame.lookVector = trs.CFrame.lookVector;
end);
end
end);
Let me know which one you tried, and also feel free to let me know if you did get any errors because I just types all of this off of the top of my head, since I am always really busy.
I hope this helped.
2 comments
This helped too thank you.
np