How to change Camera's base orientation?

Okay so, I’m a bit stumped on this topic. My goal is to rotate the camera depending on the character’s orientation. The only example of this I can find at all is of EgoMoose’s gravity controller with a fixed camera:

Post:
Wall stick/Gravity Controller.
Game:
Wall stick controller new camera - Roblox

I guess my issue is that I am having trouble understanding what exactly he does to achieve this. I’ve looked over his source code and whatnot. But I can’t for the life of me figure out how he’s moving the camera. I know it has something to do with the normals of whatever he is standing on, I understand sort of how he is calculating it. But what he does to actually manipulate the camera itself is beyond me. Maybe I’m just being dense and can’t see whatever lines of code he is using to achieve this are. But I’ve had enough trouble where I feel the need to make a post and ask for help.

Typically manipulating the camera with CFrame bugs it out for me. I can change the Camera’s Z CFrame orientation fine, but X and Y are a little more of a challenge, they don’t work like the Z axis. But as of now I can’t find a way to have the camera orientate with the player’s axis rather than the world axis, if this makes sense. I can change the Z’s rotation to 180 and the camera would be upside down, but the controls would be inverted. If I had the camera tilted sideways, dragging the camera left and right would not function the same as it would if the camera was upright.

I don’t want the camera to act like the CameraType Attach where it stays behind the player, nor do I want it’s cameratype to be “scriptable”. I want the player to have full control over their camera, and remain in the mode “Custom”. What I am hoping to achieve in this post is perhaps some sort of guidance. I assume I’ll have to override the player’s default camera modules they spawn in with. But I’m a little stumped on what to do and what to change.

1 Like

It took me a hot minute to find some of these links as they’re quite old, but I have in different places posted pretty in-depth details about this problem specifically.

I modify the player module itself to actually apply the changes to the camera which can be easy to miss b/c that code is so dense and I’m only touching it in a few places.

For a in depth description of how I adjust the tilt of the camera see this post:

The exact methods and places you adjust are now out of date b/c the player module has changed, but it gives you a general idea of where they’re being shoved into the code in a larger sense.

Mind you the above link does not explain spin. However, that is explained in this post:

This leads me to my final link which is simply a version of the modified camera controller in a format that cuts out the vanilla player module stuff.

2 Likes

This is somewhat what I achieved using RenderStepped, since it syncs with the Camera, by just updating the CFrame.Angle Z, now its upside down and the player can still walk normally.

game:GetService("RunService").RenderStepped:Connect(function(deltaTime: number) 
	workspace.CurrentCamera.CFrame*= CFrame.Angles(0,0,math.rad(140)) 
end)
1 Like

I was not expecting to get a reply from the Moose himself, made my day. I appreciate the links, I’ll do some digging around in them. Thank you!