The top clip is what i want, the second clip is what i have right now. In my version the camera seems glued to the right arm of the character whereas in the top clip its on the right side, this becomes a problem when the character is facing the screen, in the version i want the camera remains focused on the right side of the character whereas in my version it remains focused on the character’s right side.
If my hunch is correct this piece of code adds 2 to the right of the root part in it’s local space which translates to that “attachment” to the right side of the root part.
You’ll have to change your approach by taking the camera’s viewing angle and then offsetting the camera’s position CFrame from the HumanoidRootPart depending on the camera viewing angle’s RightVector property.
The camera behavior you’re trying to replicate is identical to that of a spring. You can use Quenty’s Spring module to achieve the same effect, it’s very lightweight & straightforward to use.
Springs are used to smooth things out. They’re very useful and make camera movement’s smooth but don’t do alignment though.
Here is some code that should do what you’re looking for:
-- Goes in StarterCharacterScripts
local RunService = game:GetService("RunService")
local character = script.Parent
local humanoid = character:WaitForChild("Humanoid")
local hrp = character:WaitForChild("HumanoidRootPart")
local camera = workspace.CurrentCamera
local function beforeCamera(delta)
-- Code in here will run before the default Roblox camera script
-- Offsets the camera 2 studs in the "right direction" of the camera
local worldCameraOffset = camera.CFrame.RightVector * 2
local characterCameraOffset = hrp.CFrame:VectorToObjectSpace(worldCameraOffset)
humanoid.CameraOffset = characterCameraOffset
end
-- Bind the update to run before the camera update
local NAME = "Alignment before camera"
RunService:BindToRenderStep(NAME, Enum.RenderPriority.Camera.Value - 1, beforeCamera)
humanoid.Died:Once(function()
-- Remove the binding when the character dies (could also be when a new character is added with player.CharacterAdded, getting the player from `character`)
RunService:UnbindFromRenderStep(NAME)
humanoid.CameraOffset = Vector3.new(0,0,0)
end)
Basically it sets the camera offset each frame to be 2 studs in the “right” direction of the camera’s orientation/CFrame.
Oh my god its perfect tysm. Comments are super helpful as well I’m going to read up on all of this, seriously can’t thank you enough for your help, as with everyone else in this thread.