the title says it all, i want to add some smooth tilting to this wallrun script (the logic behind the wallrunning isnt being shown):
runService.RenderStepped:Connect(function()
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = filter
raycastParams.FilterType = Enum.RaycastFilterType.Include
raycastParams.IgnoreWater = true
local origin = root.Position
local Rdirection = root.CFrame.RightVector * 3
local Ldirection = root.CFrame.RightVector * -3
local Rdistanceray = workspace:Raycast(origin,Rdirection, raycastParams)
local Ldistanceray = workspace:Raycast(origin,Ldirection, raycastParams)
if Ldistanceray and not Rdistanceray and landed == false and climbing == false and holdingSpace == true and torso.Velocity.Y > -40 and torso.Velocity.Y < -1 then
--wallrun Left
elseif not Ldistanceray and Rdistanceray and landed == false and climbing == false and holdingSpace == true and torso.Velocity.Y > -40 and torso.Velocity.Y < -1 then
--wallrun Right
elseif Ldistanceray and Rdistanceray and landed == false and climbing == false and holdingSpace == true and torso.Velocity.Y > -40 and torso.Velocity.Y < -1 then
--wallrun on both sides
elseif (landed == true or holdingSpace == false) or (not Ldistanceray and not Rdistanceray) or (torso.Velocity.Y < -35 and torso.Velocity.Y < -1) then
--Stops wallrun
end
end)
Can’t you just tween it? I would’ve thought you would be able to tween slightly left or right and use a cframe to keep that added tilt, might be wrong cause I haven’t worked with camera manipulation a whole lot
It’d probably be the easiest way if you want easing because I can’t imagine coding easing into a CFrame in renderstepped would be fun at all, but yeah I have no clue what’d be the best in terms of efficiency
i asked chatgpt and now i have this, it does work but it keeps glitching for some reason
code:
local tiltAngle = 15
local currentTilt = 0
local targetTilt = 0
runService.RenderStepped:Connect(function()
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = filter
raycastParams.FilterType = Enum.RaycastFilterType.Include
raycastParams.IgnoreWater = true
local origin = root.Position
local Rdirection = root.CFrame.RightVector * 3
local Ldirection = root.CFrame.RightVector * -3
local Rdistanceray = workspace:Raycast(origin,Rdirection, raycastParams)
local Ldistanceray = workspace:Raycast(origin,Ldirection, raycastParams)
targetTilt = 0
if Ldistanceray and not Rdistanceray and landed == false and climbing == false and holdingSpace == true and torso.Velocity.Y > -40 and torso.Velocity.Y < -1 then
targetTilt = -tiltAngle
--wallrun Left
elseif not Ldistanceray and Rdistanceray and landed == false and climbing == false and holdingSpace == true and torso.Velocity.Y > -40 and torso.Velocity.Y < -1 then
targetTilt = tiltAngle
--wallrun Right
elseif Ldistanceray and Rdistanceray and landed == false and climbing == false and holdingSpace == true and torso.Velocity.Y > -40 and torso.Velocity.Y < -1 then
--wallrun on both sides
elseif (landed == true or holdingSpace == false) or (not Ldistanceray and not Rdistanceray) or (torso.Velocity.Y < -35 and torso.Velocity.Y < -1) then
--Stops wallrun
end
currentTilt = currentTilt + (targetTilt - currentTilt) * 0.1
local camCF = CFrame.new(camera.CFrame.Position, camera.CFrame.Position + camera.CFrame.LookVector)
camCF = camCF * CFrame.Angles(0, 0, math.rad(currentTilt))
camera.CFrame = camCF
end)