How to make camera turn around smoothly for wall jump mechanic

I am currently making a wall jumping ability for my first person game. Currently, wall jumping will turn your camera around instantly, but this looks bad, so I want to make it so your camera turns around smoothly, so it feels more realistic as you jump from wall to wall.

I tried tweening, but that won’t work because it’ll tween at the position the tween was triggered, rather than updating with the position of the character’s head.

Current code:

Humanoid.AutoRotate = true
HumanoidRootPart.Anchored = false
Character.Torso.WallJump:Play()
Character.Torso.WallDrag:Stop()
Character.Torso.Dive:Play()
local BodyVelocity = Instance.new("BodyVelocity", HumanoidRootPart)
BodyVelocity.MaxForce = Vector3.new(400000, 400000, 400000)
BodyVelocity.Velocity = -HumanoidRootPart.CFrame.LookVector * Settings.LookVectorMultiplier + Vector3.new(0, Settings.JumpHeight, 0)
game.Debris:AddItem(BodyVelocity, 0.1)
HumanoidRootPart.CFrame *= CFrame.Angles(0, math.rad(180), 0)
if game.Players.LocalPlayer.CameraMode == Enum.CameraMode.LockFirstPerson then
	workspace.CurrentCamera.CFrame *= CFrame.Angles(0, math.rad(180), 0)
end
WallJumping = false
task.spawn(function()
repeat task.wait() until Humanoid.FloorMaterial ~= Enum.Material.Air
	LastWall = nil
	Character.WallJumpDeb.Value = false
end)
2 Likes

bumping

blah blah character limit and whatnot

I can suggest using a for loop or RunService.RenderStepped to update the rotation.

The implementation you have here is pretty close, so here is one with RunService:

local turningCamera = false
local camAngle = 0
local maxAngle = 180
local turnSpeed = 30
RunService.RenderStepped:Connect(function(t, delta) --delta is the delta time (how many milliseconds passed since the last frame)
  if turningCamera then
    local turn = turnSpeed * delta
    camAngle += turn
    workspace.CurrentCamera.CFrame *= CFrame.Angles(0, math.rad(turn), 0)
    if camAngle >= maxAngle then --the goal is reached, we can stop turning
      turningCamera = false
    end
  end
end)

Your other parts of the script have to be modified a bit for this to work properly though.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.