Difficulty with custom camera

I want to make the camera move around the player instead of being fixed on a point, similar to this game: [NEW ROOMS] Murder Mansion Showcase - Roblox but, I don’t know how to achieve this. At first, i though camera offset, but that’s not what I’m looking for, it just changes the point the camera is fixed on.

2 Likes

Sorry, I dont understand your question. The camera to move around the player? Similar to when any player can rotate their cameras with mouse and rightClick, etc?
What do you mean by “instead of being fixed on a point”? The default camera is not fixed, is dynamic and rotates around the player focusing the character.

I tested the game you suggested (would be better if you show a video) I tested the game and seems kinda broken, my head is spinning like crazy on all axis… It kinda tries to follow the mouse movement at the same time moving the camera similar to when I hold right click and rotate it

1 Like

ok, my bad for the late reply, what i mean is, i want the camera to be on the right of the character when it is facing forwards, but when you turn the camera to look behind you it ends up on the leftshoulder, because it moves around it. The normal camera is focused on one point, and you move it around that point.

2 Likes

Sounds a little complicated… Cause you want 2 focus points depending on the angle of rotation of the camera?

When facing forward the camera should have a offset position, placing it at the right shoulder and with focus forward (thats simple). The center of rotation pivot of the camera could be right shoulder too. But.
You want that the more you rotate the camera it shifts its rot pivot and camera focus to the left shoulder, which means depending of angle of rotation it should select different pivot and focus. math!

You sure you dont mean that you only want a simple offset of the camera position and focus? to have the camera on the right shoulder and looking forward and use that pivot for center of rotation and focus?

1 Like

Well, for more clarification, I want the camera to basically move forwards around the player, like it’s going straight but attached to a string. I could do that with rotation, but that breaks the z axis.

1 Like

Like, normally changing its position rotating around the player but always looking forward? not focusing on the player? focusing forward always

2 Likes

No, i don’t want it to be focused on the player, I want it to go around the player.


This is from the game i sent, i want the camera to be like that.

2 Likes

Mmm… why that game was not working for me?.. Im gonna check it again

Actually its similar to the first idea I got. Depending on the angle of the camera the rotation pivot changes from right to left and vice-versa. Its not noticeable in the video but the character is always at the left side of the screen no matter the rotation of the camera.

So yeah, the rotation center of the camera is simply moving right-left, depending on the angle of the camera

1 Like

Got it to work:

Here’s the code for anyone wondering:

– Variables –
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Hum = Character:WaitForChild(“Humanoid”)
local Cam = workspace.CurrentCamera

– Services –
local runService = game:GetService(“RunService”)

– Code –
Hum.CameraOffset = Vector3.new(2,-3,0)
runService.Heartbeat:Connect(function(delta)
local x,y,z = Cam.CFrame:ToObjectSpace(Character.HumanoidRootPart.CFrame):ToOrientation()

Hum.CameraOffset = Vector3.new(math.cos(y) * 2,0,0)
end)

1 Like

You got it pretty quick! Awesome! Great work.
Now that I look your code it makes sense, the offset is dynamic, you got a more elegant and simpler solution compared of what I was having in mind for a first test :partying_face:

1 Like

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