I have a system which has been coded to walk on walls and the roof. The gravity switching works, and so does the camera system. However, getting the player to move in the right direction relative to their camera and their axis is difficult.
So far, I have tried to translate the humanoid.MoveDirection property into a new vector, relative to the player’s camera and gravity axis. However, this gives inconsistent results, and overall does not seem to be working. I want the walking system to resemble regular walking, as if the player is walking regularly on the floor.
So far, I have tried a lot of different methods. They all subscribe to the idea of taking the MoveDirection and manipulating it relative to the camera, the gravity controller part, or both. See an example attempt:
local camera : Camera? = workspace.CurrentCamera
local gravityController : Part = workspace.GravityController
while humanoid.Parent ~= nil and humanoid.Health > 0 do
local relativeCFrame = camera.CFrame.Rotation:ToObjectSpace(gravityController.CFrame.Rotation)
local movingDirection = gravityController.CFrame.Rotation:VectorToWorldSpace(humanoid.MoveDirection)
cm.MovingDirection = movingDirection
local speed = cm.BaseMoveSpeed
if cm.MovingDirection.Magnitude > 0.1 then
isMoving = true
cm.FacingDirection = cm.MovingDirection
else
cm.FacingDirection = rootPart.CFrame.LookVector
end
task.wait()
end
If anyone is decent at vector maths, let me know if using the MoveDirection is even possible for my task, and if not what I can do instead.