How to make camera rotate with character?

The title says it all.

Basically I have this FPS game and on this parkour map I have a spinning platform, the character is spinning as it should, but the camera isn’t.

It’s also worth mentioning that I’m using a hinge constraint motor to move the platform and not any script.

This is how the character is rotating:

And this is how the camera is rotating: (it actually isn’t rotating at all)

Is there any fix for this?

1 Like

I’ll leave it to you to detect if the player is on a rotating part, but here’s how you could probably rotate it.

local char = game.Players.LocalPlayer.Character
cam.CFrame = CFrame.new(cam.CFrame.p,char.HumanoidRootPart.CFrame.LookVector * 10)

You can use Egomoose’s gravity controller, which does this out of the box (just remove the local script it uses to change the gravity direction):

You might also be able to calculate the difference in rotation of the HRP between each frame then apply that to the Camera.CFrame right after the character controller does using some code like this:

local RunService = game:GetService("RunService")

local function afterCamera(delta)
	-- Code in here will run after the default Roblox camera script
	-- Change the camera.CFrame's rotation by the difference in the HRP rotation
end

RunService:BindToRenderStep("Before camera", Enum.RenderPriority.Camera.Value + 1, beforeCamera)

I have tried changing the camera’s cframe to match rotations, but this most likely results in the camera not being moveable which I don’t want to happen

I went to test Egomoose’s gravity controller experience and it doesn’t do it

Or am I missing something?

1 Like

Whoops! I meant the wall stick controller from the same article, not the gravity controller.

I tested this one and it works:

ScreenRecording2024-09-11at10.06.10AM-ezgif.com-video-to-gif-converter

There is also the one with a newer camera that also probably works and has a better camera:

Yep, this worked. Pretty clever not gonna lie.

I spent some hours going through Egomoose’s wall stick controller code and after understanding it I deleted everything except the stuff that messed with the camera to get the effect I want.

Thanks!

1 Like

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