How would I make a custom character follow the camera on the X axis?

I’ve tried using ToWorldSpace but the player floats to the camera.

This is my own character controller

Here’s the code

local offsetCFrame =
plra.CFrame = plra.CFrame:ToWorldSpace(offsetCFrame)
1 Like

Do you mean move towards the mouse position?
Or something like a custom shift lock?

No I mean move in the direction the camera is. It’s a custom controller I’m developing not a custom shift lock.

I’ve tried using UpVector RightVector but there’s none for forwards and backwards.

Do you have a video of what you are trying to achieve? I don’t understand the effect.

Are you talking about moving to the mouse? Or going forward to where the camera is facing?

Did you read what I just said?

Again. Can you please look at this?

That’s a video showing your bug, not what you want to make.

Yes, I read it. I just don’t understand what you mean by this? That’s why I am asking…
From what I understand, you want to achieve this:
Is that correct?

Yes that is indeed correct.
Just lookvector or any others aren’t working.

I am not completely sure, but I believe you can use BodyGyro (to face towards the Camera LookVector) on the main part of the character.

I’ll test it real quick and get back to you.

The character is anchored and also uses my own gravity system.

1 Like

Here’s the updated code btw. It doesn’t stay on the X axis though.

		local offsetCFrame =
		plra.CFrame = plra.CFrame * offsetCFrame

So you want something like this?

No I mean with a movement system not a look at camera thing.

I was able to achieve this effect by constantly CFraming.
I don’t have your character, but all parts are connected to each other, so you can just use something like this:

local RunService = game:GetService("RunService")
local plr = game:GetService("Players").LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait() --Get the character
local cam = workspace.CurrentCamera
local speed = 2 --CFraming speed
RunService.RenderStepped:Connect(function() --Every frame do
	char:SetPrimaryPartCFrame(char:GetPrimaryPartCFrame() + * speed,0,cam.CFrame.LookVector.Z))
	--^Move towards the X and Z of the camera

--This is a local script

I don’t know whether your game is 2D or 3D, so I made mine with both X and Z.
Just replace speed,0,cam.CFrame.LookVector.Z with 0 if you want it only on the X.


Works like a charm! Thank you very much!

1 Like