So, recently I’ve been working on an OTS (Over-The-Shoulder) Gun system, here’s a brief explanation on what it is. It’s pretty much a third person gun system with the camera located over the shoulder, it has been a trend for a long time.
I have an issue with my gun system, that is being the camera placement, everything works well besides the camera. I’ve tried using Humanoid.CameraOffset, I’ve even tried using modules I got from the toolbox but none of them work, although Humanoid.CameraOffset is the closest to what I want and looks really good, sometimes there are issues and CameraOffset tend to be really unreliable, hence why I do not want to use them.
With Humanoid.CameraOffset:
I’ve also had some ideas on manually changing the Camera’s CFrame using RunService.RenderStepped, but I’m not sure where I should begin, because when I did this, I messed it up completely. I don’t need full scripts, I just need at the very least an idea on how to do it, I’d appreciate some links that could help me as well.
3 Likes
Bumping this topic, I still need help.
There are plenty of youtube tutorials that can help you make a third person camera like that, such as this video
It goes over how to create a third person camera with CFraming, and also if you don’t need the tools to be collidable, disable cancollide for the models
1 Like
I’ll check the video out! Tysm!
1 Like
I believe the issue with the current method is how the autorotate and the camera interfere with each other at high angle.
Assuming the camera doesn’t roll around you can restrict the camera by clamping it’s orientation like I have done for my turrets. This way you can keep your method and avoid the looking directly down glitch. Cons are that you can’t directly look down.
Here is how I clamp my angles:
local ConstraintsTemplate = {
["YawLeft"] = 5;
["YawRight"] = 5;
["ElevationAngle"] = 40;
["DepressionAngle"] = 40;
}
-- negative z is front, x is rightvector
function TurretController:EulerClampXY(x,y)
local Constraints = self.Constraints --Dictionary containing the amount of clamping variables
local degY = math.deg(y)
local degX = math.deg(x)
local newY = math.clamp(degY,-Constraints.YawRight,Constraints.YawLeft)
local newX = math.clamp(degX,-Constraints.DepressionAngle, Constraints.ElevationAngle)
return math.rad(newX), math.rad(newY)
end
-- then in the script
local x , y , z = turretRelativeCF:ToOrientation()
local constrainedX , constrainedY = self:EulerClampXY(x,y)
local newConstrainedCFrame = CFrame.fromOrientation(constrainedX,constrainedY,z)
--In your case it should be something like this
local x , y , z = camera.CFrame:ToOrientation()
local constrainedX , constrainedY = self:EulerClampXY(x,y)
local newConstrainedCFrame = CFrame.fromOrientation(constrainedX,y,z)
camera.CFrame = newConstrainedCFrame
--limit the angle from looking too much down or up
1 Like