I have recently been scripting a custom character controller discarding Roblox’s default character controller.
I have set up a moveDirection and want the move direction to mach up with the direction of the camera
ex.
dependent on the direction of the camera is concluding what direction forward is.
here is my moveDirection code only working for 1 camera angle
if table.find(inputs, Enum.KeyCode.W) and not W_ then
moveVector.Value = moveVector.Value - Vector3.new(0, 0, 1)
W_ = true
elseif not table.find(inputs, Enum.KeyCode.W) and W_ then
moveVector.Value = moveVector.Value + Vector3.new(0, 0, 1)
W_ = false
end
if table.find(inputs, Enum.KeyCode.A) and not A_ then
moveVector.Value = moveVector.Value - Vector3.new(1, 0, 0)
A_ = true
elseif not table.find(inputs, Enum.KeyCode.A) and A_ then
moveVector.Value = moveVector.Value + Vector3.new(1, 0, 0)
A_ = false
end
if table.find(inputs, Enum.KeyCode.S) and not S_ then
moveVector.Value = moveVector.Value + Vector3.new(0, 0, 1)
S_ = true
elseif not table.find(inputs, Enum.KeyCode.S) and S_ then
moveVector.Value = moveVector.Value - Vector3.new(0, 0, 1)
S_ = false
end
if table.find(inputs, Enum.KeyCode.D) and not D_ then
moveVector.Value = moveVector.Value + Vector3.new(1, 0, 0)
D_ = true
elseif not table.find(inputs, Enum.KeyCode.D) and D_ then
moveVector.Value = moveVector.Value - Vector3.new(1, 0, 0)
D_ = false
end
VEL.Velocity = moveVector.Value * 10 -- camera???
If I understand correctly based on the picture, you want the camera to always be anchored behind the moveDirection?
Why not use RenderStepped to constantly set the CFrame of the camera to the moveDirection’s position and directon and then multiply it by something like CFrame.new(0, 0, -5) to move it 5 studs back?