I’m trying to make my own movement script and I thought a good place to start would be to go through the PlayerModule script and put anything related to making the player move in a new script so that I can change things to my liking and then integrate it with my code. I got everything to work except for getting the player to walk in the direction of the camera.
Full Code:------------------------------------------------------------------------------ - Pastebin.com
This is the function that I assume makes the player move in the cameras direction not sure why it’s not working though
local function CalculateRawMoveVector(humanoid: Humanoid, cameraRelativeMoveVector: Vector3): Vector3
local camera = workspace.CurrentCamera
if not camera then
return cameraRelativeMoveVector
end
if humanoid:GetState() == Enum.HumanoidStateType.Swimming then
return camera.CFrame:VectorToWorldSpace(cameraRelativeMoveVector)
end
local cameraCFrame = camera.CFrame
local c, s
local _, _, _, R00, R01, R02, _, _, R12, _, _, R22 = cameraCFrame:GetComponents()
if R12 < 1 and R12 > -1 then
-- X and Z components from back vector.
c = R22
s = R02
else
-- In this case the camera is looking straight up or straight down.
-- Use X components from right and up vectors.
c = R00
s = -R01*math.sign(R12)
end
local norm = math.sqrt(c*c + s*s)
return Vector3.new(
(c*cameraRelativeMoveVector.X + s*cameraRelativeMoveVector.Z)/norm,
0,
(c*cameraRelativeMoveVector.Z - s*cameraRelativeMoveVector.X)/norm
)
end