Custom player camera - character movement now buggy

So, I’m trying to make an over-the-shoulder type camera. I’ve tried to do this kind of this before but I’ve always come across the same problem - how do I make the character still walk in the direction it needs to relative to the camera?

Images of how my camera looks so far




Right now, whenever the camera isn’t facing straight forward in the direction the character is facing, pressing any movement key makes it spin quickly in that direction, which isn’t what I want. I’m looking for something so the character just keeps moving that way.

For example, with this image - if the character pressed A then they’d keep going in the way they are facing now. If D was pressed, they’d go the opposite way. If W was pressed, they would move towards the mouse (and so on).

Your explanation is a bit confusing but perhaps this is what you need? Relative to Camera is part of it.

Yeah I’m aware of this, but that means I have to disconnect the WASD controls from the ControlScript. It’s annoying doing that but I’m not sure if there’s another way.

The MasterControl module handling the player’s movement contains a call to :Move as method of a player, if you can override the MasterControl module by copying it and altering it you can change the RelativeToCamera flag in it.

in MasterControl;

local moveFunc = LocalPlayer.Move
local updateMovement = function()
	
	if not areControlsEnabled then return end
	
	local humanoid = getHumanoid()
	if not humanoid then return end
	
	if isJumpEnabled and isJumping and not humanoid.PlatformStand then
		local state = humanoid:GetState()
		if state ~= STATE_JUMPING and state ~= STATE_FREEFALL and state ~= STATE_LANDED then
			humanoid.Jump = isJumping
		end
	end

	moveFunc(LocalPlayer, moveValue, true)
end

where moveFunc is;

I think I know what I am doing wrong. It’s not because it’s not relative to the camera. I’ll mark it as solved when I am sure I’ve solved it.

What were you doing wrong?

My camera was attached to the character - instead of being able to rotate around a vector point. Fairly simple fix, just use a vector instead of a cframe for choosing your character’s position. Hopefully this’ll help other people with this problem. It’s surprisingly easy to make a custom camera.

1 Like

What do you mean by this? When I set this up with my script, It rotates the player but not the camera. Any help? This is the source:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:wait()
local Cam = workspace.CurrentCamera
local UIS = game:GetService('UserInputService')
local RunService = game:GetService('RunService')
local TweenService = game:GetService("TweenService")

local Zoom = Instance.new('NumberValue')
Zoom.Value = 0

UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
UIS.MouseIconEnabled = false

Player.CharacterAdded:connect(function(CharacterAdded)
	Character = CharacterAdded
end)

RunService.RenderStepped:connect(function()
	if Zoom.Value < 0 then
		Zoom.Value = 0
	elseif Zoom.Value > 2 then
		Zoom.Value = 2
	end
	if Character then
		Cam.CFrame = CFrame.new(Character.HumanoidRootPart.Position) * CFrame.new(2,5+Zoom.Value,5+Zoom.Value) * CFrame.Angles(math.rad(-15),0,0)
	end
end)

UIS.InputChanged:connect(function(Input, GPE)
	if not GPE then
		if Input.UserInputType == Enum.UserInputType.MouseWheel then
			if Zoom.Value >= 0 and Zoom.Value <= 2 then
				if Input.Position.Z == -1 then
					local goal = {Value = Zoom.Value+1}
					local tweenInfo = TweenInfo.new(0.1)
					local tween = TweenService:Create(Zoom, tweenInfo, goal)
					tween:Play()
				elseif Input.Position.Z == 1 then
					local goal = {Value = Zoom.Value-1}
					local tweenInfo = TweenInfo.new(0.1)
					local tween = TweenService:Create(Zoom, tweenInfo, goal)
					tween:Play()
				end
			end
		elseif Input.UserInputType == Enum.UserInputType.MouseMovement then
			Character.HumanoidRootPart.CFrame = Character.HumanoidRootPart.CFrame * CFrame.Angles(0, math.rad(-Input.Delta.x/5),0)
			-- Cam.CFrame = Cam.CFrame * CFrame.Angles(0,math.rad(-Input.Delta.x/5),0)
		end
	end
end)

I want it to be able to rotate the camera with the player, and when A, S and D are pressed for the camera to not spin around. This is what I’m talking about:

Before:
https://gyazo.com/3168da5657ff97fb633916b90a8666ff
After:
https://gyazo.com/445d312f3e5690c76e664dad12066e0f