#Any ideas of how to make a Locked Smooth Camera follow Vehicle?

1 messages · Page 1 of 1 (latest)

fluid torrent
#

This is how I wanted it to look like

drowsy bramble
#

Set the camera mode to follow

fluid torrent
# drowsy bramble Set the camera mode to follow

I want the camera to be almost "locked" to a part, as we would set camera.CFrame = cameraPart.CFrame, because follow makes you be able to rotate the camera with the right click of the mouse, and the camera is too far away from the car.

#

some vehicles will have different cameras positions

drowsy bramble
#

Oh boy do I have the solution for you

fluid torrent
#

I saw a video that a guy has made with the camera set to scriptable and he used the spring module, he made the tutorial and did not showed the functions that return certains values to it

fluid torrent
#

he did not showed the functions

drowsy bramble
#

OH BOY DO I HAVE THE SOLUTI-

#

Gimme a min

fluid torrent
#

ok

drowsy bramble
#

I'm using it in a project rn

#

Very simple to use

#

And very good

fluid torrent
#

hmm

#

i'll try it out

drowsy bramble
#
game.RunService.PreRender:Connect(function(delta)
    Spring.target(camera, 1, 3, {CFrame = car:GetPivot() * CFrame.new(0, 0, 10)})
end)
#

Make sure to set the camera to Scriptable

drowsy bramble
#

Did you use PreRender?

fluid torrent
#

Yes, I used the RunService.PreRender

drowsy bramble
#

Not sure what's wrong then

fluid torrent
#

When it goes at high speed the camera starts "glitching"

#

I dont know if its because the camera is trying to reach the point and then the car deslocates its point to another, because its moving

#

I dont know if there would be a way that might exist a "artificial" lerp that has a "range" and stops it from happening

fluid torrent
#

might be the solution but the "getClosestAngles" is the one who I have no idea what it would return

#

the rest of it I kinda have an idea of how it might work

#

getPositionAndAnglesFromCFrame() might be something returning like: goal.Position, goal.Rotation

#

the getCFrameFromPositionAndAngles is probably something like return CFrame.new(position) * CFrame.Angles(angles)

#

Oh, I used the AlignPosition and Orientation and it worked so smoothly

drowsy bramble
#

What did you use it on?

#

The car?

fluid torrent
#

Yes, I was playing with it. This is how the code looks like now:

local Attachment = Instance.new("Attachment", CameraPart)
    
    local AlignPosition = Instance.new("AlignPosition", CameraPart)
    AlignPosition.MaxForce = 1000
    AlignPosition.MaxVelocity = 0
    
    AlignPosition.Attachment0 = Attachment
    AlignPosition.Attachment1 = ReferenceA
    
    AlignPosition.Mode = Enum.PositionAlignmentMode.TwoAttachment
    
    AlignPosition.ForceLimitMode = Enum.ForceLimitMode.PerAxis
    AlignPosition.ForceRelativeTo = Enum.ActuatorRelativeTo.Attachment0
    
    AlignPosition.Responsiveness = 25
    
    local AlignOrientation = Instance.new("AlignOrientation", CameraPart)
    AlignOrientation.MaxTorque = 1000
    AlignOrientation.Responsiveness = 15
    
    AlignOrientation.Attachment0 = Attachment
    AlignOrientation.Attachment1 = ReferenceA
    
    AlignOrientation.CFrame = CameraReference.CFrame.Rotation
    
    --/ Variables
    local LatestDeltaTime = 0
    
    --/ Render
    RunService:UnbindFromRenderStep("Camera")

    local cameraOffset = CFrame.new(0, 2.5, 20)
    
    local Connection =  RunService.RenderStepped:Connect(function()
        GetCameraType(Enum.CameraType.Scriptable)
        
        -- CameraPhysics.target(Camera, 1, 3, {CFrame = Chassis:GetPivot() * cameraOffset})
        
        Camera.CFrame = CameraPart.CFrame
    end)``` in the case you want to know too