Simply put, it works well, and I’m happily using it in my game. Highly recommended for anyone looking to enhance their game’s camera experience.
We’re still looking to show some love! If you’re using CameraService in any current or past projects of yours, let me know, and I can link it in the OP!
Is there a suitable method to implement a feature similar to what “REALISM” provides? Where players can virtually aim weapons in the direction the character is looking?
Hello ive noticed one error, when switching to Default, the character doesnt rotate towards the camera. I tried turning on AutoRotate but to no effect. How can I fix this?
https://gyazo.com/9b56a356a51b804c4daf6ccebd91269c
I thought I got this version, But I noticed when holding tools and moving backwards, my characters jitter quite a lot.
Could you send a video and the file that you’re using?
Does this allow for camera spots such as a cutscene? Also for the 1st person camera could we customize it, such as changing the amount of body visible by looking down?
I was unsure if you meant here or your messages, I logically chose the latter, lol. But I sent it
Yes!
Technically, you could do cutscenes in CameraService by creating a camera view, setting the host to a part, and then tweening that part. However, I personally would recommend disabling CameraService and simply interpolating/tweening yourself.
And for the 1st person camera, yes! There’s a statement on Lines 267 and 444 (if I remember correctly), where you can alter the angles from 60 degrees to something else. If more people have a use to alter it, I’d be happy to make altering that a bit easier in a future release!
v2.1.0 is out!
Patches to the backwards jittery motion, Default motion issues, output error spam, as well as a new method to change vertical range of motion (:SetVerticalRange(angle: number)
) are out now on both GitHub and Roblox Marketplace!
Sweet! would this VerticleRange have a use-case for something like recoil effect for the camera?
To be honest, I don’t see recoil being a heavy use-case for this (probably more use of :Shake or the Offset property), but definitely great if you need to restrict the range of motion for something, like looking through a telescope.
I thought i should post here since my attempted soulution involves the LockCameraPanning method. The video explains the problem better than I can.
robloxapp-20240409-1318299.wmv (3.3 MB)
local c = script.Parent
local holdingKey = false
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
-- Ensure that the character's humanoid contains an "Animator" object
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")
local uis = game:GetService("UserInputService")
local leftAnimation = Instance.new("Animation")
leftAnimation.AnimationId = "rbxassetid://17014677879"
-- Wallrun Camera
local CameraService = require(game.ReplicatedStorage.Dependencies.CameraService)
local information = {
Smoothness = .6,
CharacterVisibility = "All",
MinZoom = 10,
MaxZoom = 10.001, --> To avoid running into math errors, make sure MaxZoom and MinZoom have a difference of at least 0.001.
Zoom = 10,
AlignChar = true,
Offset = CFrame.new(2,0,0),
LockMouse = true,
BodyFollow = false
}
local information2 = {
Smoothness = .6,
CharacterVisibility = "All",
MinZoom = 10,
MaxZoom = 10.001, --> To avoid running into math errors, make sure MaxZoom and MinZoom have a difference of at least 0.001.
Zoom = 10,
AlignChar = false,
Offset = CFrame.new(),
LockMouse = false,
BodyFollow = false
}
CameraService:CreateNewCameraView("WallrunCamera", information)
CameraService:CreateNewCameraView("Aim", information)
CameraService:CreateNewCameraView("Unlock", information2)
-- Load the animation onto the animator
local leftAnim = animator:LoadAnimation(leftAnimation)
local rightAnimation = Instance.new("Animation")
rightAnimation.AnimationId = "rbxassetid://17014672160"
-- Load the animation onto the animator
local rightAnim = animator:LoadAnimation(rightAnimation)
rightAnim.Priority= Enum.AnimationPriority.Action2
uis.InputBegan:Connect(function(inp, p)
if not p and inp.KeyCode == Enum.KeyCode.LeftShift then
holdingKey = true
end
end)
uis.InputEnded:Connect(function(inp)
if inp.KeyCode == Enum.KeyCode.LeftShift then
CameraService:LockCameraPanning(false, false)
holdingKey = false
end
end)
game:GetService("RunService").Heartbeat:Connect(function()
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Exclude; raycastParams.FilterDescendantsInstances = {c}; raycastParams.IgnoreWater = true
local rayL = workspace:Raycast(c.HumanoidRootPart.CFrame.Position, -c.HumanoidRootPart.CFrame.RightVector * 2.7, raycastParams)
local rayR = workspace:Raycast(c.HumanoidRootPart.CFrame.Position, c.HumanoidRootPart.CFrame.RightVector * 2.7, raycastParams)
local ray = rayL or rayR
if ray and holdingKey then
if ray == rayL then
if not leftAnim.IsPlaying then
leftAnim:Play()
c.statusHandler.status.Value = "Wallrunning"
CameraService:SetCameraView("WallrunCamera")
CameraService:LockCameraPanning(true, true, 90)
end
rightAnim:Stop()
else
if not rightAnim.IsPlaying then
rightAnim:Play()
c.statusHandler.status.Value = "Wallrunning"
CameraService:SetCameraView("WallrunCamera")
CameraService:LockCameraPanning(true, true, 270)
end
leftAnim:Stop()
end
local part = ray.Instance
local weld = c.HumanoidRootPart:FindFirstChild("WallrunWeld") or Instance.new("WeldConstraint")
weld.Name = "WallrunWeld"
weld.Part0 = c.HumanoidRootPart
weld.Part1 = part
local bp = c.HumanoidRootPart:FindFirstChild("WallrunBodyPosition") or Instance.new("BodyPosition", c.HumanoidRootPart)
bp.Name = "WallrunBodyPosition"
bp.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bp.Position = c.HumanoidRootPart.Position + workspace.CurrentCamera.CFrame.LookVector * 10
else
for i, child in pairs(c.HumanoidRootPart:GetChildren()) do
if child.Name == "WallrunWeld" or child.Name == "WallrunBodyPosition" then
child:Destroy()
end
end
c.statusHandler.status.Value = "nil"
leftAnim:Stop()
rightAnim:Stop()
end
end)
Changing the camera when wallrunning only works when running on the right and left walls in world space and not on all walls. Thanks for any help.
I would either slightly reduce the angle (i.e. 269 instead of 270, 89 instead of 90).
On around Line 248 of the CameraService module, there’s this:
--> Allow clipping through transluscent parts
if landRay and landRay.Distance and landRay.Instance then
if landRay.Instance:IsA("BasePart") then
zoom = landRay.Instance.Transparency <= 0.4 and landRay.Distance * 0.91 or currentZoom
else
zoom = landRay.Distance - 1
end
end
You may want to change that 0.91
to something smaller to fit your needs, like 0.85.
This is a really cool module, but there some downfalls to it. What really bugs me is the Smoothness, especially for first person with viewing body parts. My game is entirely in first person, R6 and it has a crouch function. When the player crouches, the Offset is set to certain CFrame but it’s instant because I set the Smoothness to 0. This goes the same for Shake and the wobble doesn’t work.
What I’m trying to say is there should probably be a smoothness value for each property for eg.
CameraService:Change(“Offset”, cframe, smooth, false), not only one to handle everything because I don’t want a delay for when the player walks.
But overall this module is really cool for ThirdPerson, but FirstPerson should probably be worked on a little more.
Is there a way to make the player not be able to pan the camera manually, but make the camera always face the direction the player is looking at when they walk? So the player wont be able to move the camera with their mouse, but walking in a different direction makes the camera rotate with the player
I tried using :LockCameraPanning() but while it prevents the player from moving the camera, it doesn’t let the camera rotate as the player walks
I don’t believe this is natively supported by CameraService at the moment without some forking, but it’s definitely a cool idea! I’ll see if I can try to whip something up along those lines.
I’ve looked prior into seeing if I could separate smoothness between the motion and rotation, but from what I’ve attempted before, the result isn’t optimal, as the two don’t end up syncing and just makes the whole experience more janky. Now that summer’s around I could definitely experiment a bit more with it and look into it.
In the meantime, to remedy the crouching, what I would recommend is temporarily setting Smoothness to some value before wobbling and then returning it back to 0. I’d also look into having the character’s actual body move with ease, as the camera will mimic that motion and ease smoothly even at 0 smoothness.
Thank you for creating this resource. I’ve been using it a bit and it works pretty well. Just one thing I noticed though. On mobile, if the player is moving the thumbstick and using their other finger to pan the camera at the same time, the camera also zooms in. Is there any way to fix this?
any thoughts on how to create a recoil effect when on third person? the mouse seems to be locked in the middle of the screen and the shaking effect doesnt change for example precision of guns, they keep shooting straight