It clips through the camera when player hits a wall.
3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I looked up on Forum, there is a solution using Raycast, but I am still confused.
local Players = game:GetService(“Players”)
local player = Players.LocalPlayer
local character = player.Character
local humanoid = character and character:FindFirstChildOfClass(“Humanoid”)
if humanoid then
local camera = game.Workspace.CurrentCamera
local cameraOffset = humanoid.CameraOffset
local function updateCamera()
local raycastResult = workspace:Raycast(
camera.CFrame.Position,
camera.CFrame.LookVector * cameraOffset.Z,
{character}
)
if raycastResult then
local distanceToObstacle = (raycastResult.Position - camera.CFrame.Position).Magnitude
local minDistance = cameraOffset.Z * 0.5
if distanceToObstacle < minDistance then
local newCameraPosition = raycastResult.Position - camera.CFrame.LookVector * minDistance
camera.CFrame = CFrame.new(newCameraPosition, raycastResult.Position)
end
end
end
camera:GetPropertyChangedSignal("CFrame"):Connect(updateCamera)
Oh, I got it. but in my game the wall is not a custom mesh tho. Maybe there is the only way that i can do is set my humanoid camera backward a little bit.
Yeah I have no idea what to do either, I have my own problem where my viewmodel is pushing the character even though collisiongroups are off and it’s massless…