Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make it so that the camera is never offset?

Asked by
Skyyrn 1
3 years ago

Question title's a little vague, so:

I'm toying around with Roblox's endorsed Auto Rifles. Whenever I use the rifles, the camera's always offset to the right. How would I make it so that the camera isn't offset whenever I use the rifles?

(I've tried (0, 0, 0) and deleting the whole section, but it would always result in a broken rifle or the camera being set at some obscure point and won't follow the player)

function ShoulderCamera.new(weaponsSystem)
    local self = setmetatable({}, ShoulderCamera)
    self.weaponsSystem = weaponsSystem

    -- Configuration parameters (constants)
    self.fieldOfView = 100
    self.minPitch = math.rad(-75) -- min degrees camera can angle down
    self.maxPitch = math.rad(75) -- max degrees camera can cangle up
    self.normalOffset = Vector3.new(0.1, 2, 0) -- this is the camera's offset from the player
    self.zoomedOffsetDistance = 0 -- number of studs to zoom in from default offset when zooming
    self.normalCrosshairScale = 1
    self.zoomedCrosshairScale = 0.75
    self.defaultZoomFactor = 1
    self.canZoom = true
    self.zoomInputs = { Enum.UserInputType.MouseButton2, Enum.KeyCode.ButtonL2, }
    self.sprintInputs = { Enum.KeyCode.LeftShift, Enum.KeyCode.RightShift }
    self.mouseRadsPerPixel = Vector2.new(1 / 480, 1 / 480)
    self.zoomedMouseRadsPerPixel = Vector2.new(1 / 1200, 1 / 1200)
    self.touchSensitivity = Vector2.new(1 / 100, 1 / 100)
    self.zoomedTouchSensitivity = Vector2.new(1 / 200, 1 / 200)
    self.touchDelayTime = 0.25 -- max time for a touch to count as a tap (to shoot the weapon instead of control camera),
                               -- also the amount of time players have to start a second touch after releasing the first time to trigger automatic fire
    self.recoilDecay = 1 -- higher number means faster recoil decay rate
    self.rotateCharacterWithCamera = true
    self.gamepadSensitivityModifier = Vector2.new(0.85, 0.65)

Answer this question