#why does the camera initially zoom in when ragdolling?

1 messages · Page 1 of 1 (latest)

void stump
#

trying to mimic gta IV ragdoll camera, works overall but i just need help preventing the zoom

code:

RunService.RenderStepped:Connect(function(dt)
    if char:FindFirstChild("Ragdolled") and char.Ragdolled.Value == true then
        if not usingRagdollCamera and settingValue.Value == false then
            usingRagdollCamera = true
            originalCameraType = workspace.CurrentCamera.CameraType
            originalCameraSubject = workspace.CurrentCamera.CameraSubject
            cameraRig = Instance.new("Part")
            cameraRig.Size = Vector3.new(1,1,1)
            cameraRig.Anchored = true
            cameraRig.CFrame = workspace.CurrentCamera.CFrame + Vector3.new(0, math.clamp(torso.AssemblyLinearVelocity.Magnitude / 350, 0, 3), 0)
            cameraRig.CanCollide = false
            cameraRig.CanTouch = false
            cameraRig.CanQuery = false
            cameraRig.Transparency = 1
            cameraRig.Name = "CameraRig"
            cameraRig.Parent = char
            workspace.CurrentCamera.CameraSubject = cameraRig
            workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
        end
        if usingRagdollCamera and cameraRig then
            local currentPos = torso.Position
            local velocity = (currentPos - lastPos) / dt
            lastPos = currentPos
            local drag = -0.2
            local offset = -velocity * drag
            if offset.Magnitude > 15 then
                offset = offset.Unit * 15
            end
            local targetPos = torso.Position + offset
            local newY = math.clamp(torso.AssemblyLinearVelocity.Magnitude / 350, 0, 3)
            TweenService:Create(cameraRig, TweenInfo.new(0.3), {
                Position = targetPos + Vector3.new(0, newY, 0)
            }):Play()
        end
    else
        if usingRagdollCamera then
            resetCamera()
        end
    end
end)
earnest snowBOT
#

studio** You are now Level 1! **studio

peak girder
void stump
#

wdym

void stump
peak girder
void stump
#

wrong paste hol up

peak girder
#

was that the intent?

void stump
#

no

#

the camera is suppose to drag along with the player instead of attaching to it

#

do you not see the camera taking it's time reaching the player

peak girder
#

how do you know it's not working?

void stump
#

??

peak girder
#

in the reference video, the character is moving way faster than you are

void stump
#

i never said it was not working

#

i just need help removing the initial zoom

#

when ragdolling

#

as shown in the first video

peak girder
# void stump i just need help removing the initial zoom

I'm sorry, my guess is it's probably something to do with the offset. I'm assuming you're having small changes in velocity when activating ragdoll. these are just guesses. I'd also like to know what resetCamera() does out of curiosity. I'd suggest printing out and organizing all the values you use for math first

void stump
#

resetCamera() basically just resets the camera, making the camera subject back to the player's humanoid

#
local function resetCamera()
    usingRagdollCamera = false
    if cameraRig then
        cameraRig:Destroy()
        cameraRig = nil
    end
    if originalCameraSubject and originalCameraType then
        workspace.CurrentCamera.CameraType = originalCameraType
        workspace.CurrentCamera.CameraSubject = originalCameraSubject
    end
end
peak girder
#

idk why I didn't think about this till now, but changing camera subject automatically snaps the camera

#

which is probably why it does so in your example. I'm guessing you could probably see the part and rotate around it if it were to be visible

void stump
#

figured out that i just did more work than i was suppose to

#
            local currentPos = char.Head.Position
            local velocity = (currentPos - lastPos) / dt
            lastPos = currentPos
            local drag = -0.2
            local offset = -velocity * drag
            if offset.Magnitude > 15 then
                offset = offset.Unit * 15
            end
            local targetPos = char.Head.Position + offset

i actually never needed this part

#

i couldve just let it tween, and the wait time would just delay the camera for me

#

and whaddaya know, i deleted that part and now its fixed

latent kraken
#

I'm not adding to help or anything but that looks rlly good

#

the clips of the ragdolling

void stump
#

now it looks even better without the initial transition 👅

earnest snowBOT
#

studio** You are now Level 2! **studio