hello
Every time I lean against a wall the viewmodel should go backwards, they do that but it gets all stuck as if it were trying to go through the wall. Here is the video:
robloxapp-20250217-2150024.wmv (3.2 MB)
If anyone can help me I would be very grateful!
my code and viewmodel:
code:
Viewmodel:PivotTo(
camera.CFrame *
CFrame.Angles(UpdatedSway.Y, UpdatedSway.X, UpdatedSway.Z) *
CFrame.new(-UpdatedBob.X, -UpdatedBob.Y, 0) * aimNumber *
RaycastingPos
)
local distance = plr.PlayerGui.ScreenGui.TextBox.Text
local params = RaycastParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.FilterDescendantsInstances = {Viewmodel, plr.Character}
--local offset = Vector3.new(0, 0, 0.801) -- Offset calculado
local origin = Viewmodel.RayInitial.CFrame.Position --+ offset
local direction = Viewmodel.RayInitial.CFrame.LookVector * distance
local Result = workspace:Raycast(origin, direction, params)
if Result then
local hitDistance = (origin - Result.Position).Magnitude
RaycastingPos = RaycastingPos:Lerp(CFrame.new(0, 0, hitDistance), 0.07)
else
RaycastingPos = RaycastingPos:Lerp(CFrame.new(0, 0, 0), 0.07)
end
my viewmodel:
viewmodel.rbxm (42.1 KB)