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

The Camera's XYZ axis aren't updating as expected?

Asked by 4 years ago
Edited by Ziffixture 4 years ago

Please help!

When I'm crouched, the recoil for the camera is weird. it's difficult to explain, so watch this video to get an idea of whats happening. To get the Camera's XYZ offset to update fluidly I just use runService, though it doesn't seem to be working as smoothly.

Here's my code:

-- Shoot --
function OffsetAxis()
    x2 = Character.Humanoid.CameraOffset.X
    y2 = Character.Humanoid.CameraOffset.Y
    z2 = Character.Humanoid.CameraOffset.Z
end

-- Sets Model to Camera CFrame --
RunService.RenderStepped:Connect(function()
    viewModel:SetPrimaryPartCFrame(Camera.CFrame * CFrame.new(-0.1,-1.5,0.5))
    renderloop()
    OffsetAxis()
end)

local OffsetP = {CameraOffset = Vector3.new(x2,y2 + 0.08,z2 - 0.04)}
local Infor = TweenInfo.new(0.1, Enum.EasingStyle.Circular, Enum.EasingDirection.In)
local OffSetd = game:GetService("TweenService"):Create(Character.Humanoid, Infor, OffsetP)
local x = viewModel.Classic.Bottom.Top.C0.X
local y = viewModel.Classic.Bottom.Top.C0.Y
local z = viewModel.Classic.Bottom.Top.C0.Z
local Properties = {C0 = CFrame.new(0.5,y,z)}
local Info = TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
local Back = game:GetService("TweenService"):Create(viewModel.Classic.Bottom.Top, Info, Properties)
local lol = {CameraOffset = Vector3.new(x2,y2 - 0.08,z2 + 0.04)}
local ll = TweenInfo.new(0.1, Enum.EasingStyle.Circular, Enum.EasingDirection.Out)
local Anim = game:GetService("TweenService"):Create(Character.Humanoid, ll, lol)
local Properties2 = {C0 = CFrame.new(x,y,z)}
local Info2 = TweenInfo.new(0.1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
local Forward = game:GetService("TweenService"):Create(viewModel.Classic.Bottom.Top, Info2, Properties2)

Mouse.Button1Down:Connect(function()
    if CanShoot == true and shooting == false then
        if not Forward.Completed then
            Forward:Stop()
        end
        shooting = true
        OffSetd:Play()
        CanShoot = false
        Vandal.Fire:Play()
        Back:Play()
        wait(0.1)
        Anim:Play()
        Forward:Play()
        wait(firerate)
        CanShoot = true
        shooting = false
    end
end)

-- Crouch --

local anim = script.Crouch
local play = Character:WaitForChild("Humanoid"):LoadAnimation(anim)

UIS.InputBegan:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftControl then
        IsCrouched = true
        Character.Humanoid.WalkSpeed = 8
        local Properties = {CameraOffset = Vector3.new(x2,y2 - 0.5,z2)}
        local Info = TweenInfo.new(0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
        local T = game:GetService("TweenService"):Create(Character.Humanoid, Info, Properties)
        T:Play()
        play:Play()
    end
end)
UIS.InputEnded:Connect(function(input)
    if input.KeyCode == Enum.KeyCode.LeftControl then
        IsCrouched = false
        Character.Humanoid.WalkSpeed = 12
        local Properties = {CameraOffset = Vector3.new(x2,y2 + 0.5,z2)}
        local Info = TweenInfo.new(0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
        local T = game:GetService("TweenService"):Create(Character.Humanoid, Info, Properties)
        T:Play()
        play:Stop()
    end
end)
0
Please do not use this platform to promote or push propaganda, be it the littlest, we don't care. Focus more on making a readable question, as I had to edit the entire thing. Ziffixture 6913 — 4y
0
wait are u talking to me? i’m not the one promoting i just put a link to a video of my problem IsntItYoshi 0 — 4y
0
Is this for a FPS game? 3F1VE 257 — 4y
0
yes IsntItYoshi 0 — 4y

Answer this question