currently trying to make a camera that has a custom position and also doesn’t clip thru walls
RS:BindToRenderStep('CameraUpdate', Enum.RenderPriority.Camera.Value, function()
local startCFrame = CFrame.new(hrp.CFrame.Position) * CFrame.Angles(0, math.rad(cameraAngleX), 0) * CFrame.Angles(math.rad(cameraAngleY), 0, 0)
local cameraCFrame = startCFrame:PointToWorldSpace(cameraOffset)
local cameraFocus = startCFrame:PointToWorldSpace(Vector3.new(cameraOffset.X, cameraOffset.Y, -100000))
camera.CFrame = CFrame.lookAt(cameraCFrame, cameraFocus)
--// This part constantly updates the camera
local rayOrigin = camera.CFrame.Position
local rayDirectionUp = Vector3.new(0, 2, 0)
local rayDirectionDown = Vector3.new(0, -2, 0)
local rayDirectionLeft = Vector3.new(2, 0, 0)
local rayDirectionRight = Vector3.new(-2, 0, 0)
local rayDirectionFront = Vector3.new(0, 0, -2)
local rayDirectionBack = Vector3.new(0, 0, 2)
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {camera}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.IgnoreWater = true
local raycastResultUp = workspace:Raycast(rayOrigin, rayDirectionUp, raycastParams)
local raycastResultDown = workspace:Raycast(rayOrigin, rayDirectionDown, raycastParams)
local raycastResultLeft = workspace:Raycast(rayOrigin, rayDirectionLeft, raycastParams)
local raycastResultRight = workspace:Raycast(rayOrigin, rayDirectionRight, raycastParams)
local raycastResultFront = workspace:Raycast(rayOrigin, rayDirectionFront, raycastParams)
local raycastResultBack = workspace:Raycast(rayOrigin, rayDirectionBack, raycastParams)
if raycastResultLeft then
if raycastResultLeft.Distance <= 10 then
camera.CFrame = CFrame.new(camera.CFrame * Vector3.new(-10,0,0))
if debugging then
print(raycastResultLeft.Distance)
end
end
end
if raycastResultBack then
if raycastResultBack.Distance <= 10 then
camera.CFrame = CFrame.new(camera.CFrame * Vector3.new(0,0,-10))
if debugging then
print(raycastResultBack.Distance)
end
end
end
--//this part basically raycasts and if the distance is 10 or less its supposed to push the camera to whatever direction i put.
end)
this is basically what im running, i am unable to make the camera be constantly pushed away from the wall, this isnt fancy at the moment since im bascially just trying to get it to work first, if theres a link to a better customizable third person camera that i could use, that would be nice too