How can I make movement not based off camera position?

Hi devs,

Is there a way to make it so that player movement is based off position, rather than camera movement, while still using Roblox’s default movement system?
e.g. w moves player up on x

you can use game.Players.LocalPlayer.PlayerScripts.PlayerModule.ControlModule to get the move vector

here is a small demo that might help

Movement.rbxl (34.7 KB)

and this is the code inside the demo

local runService = game:GetService("RunService")
local controlModule = require(game.Players.LocalPlayer.PlayerScripts.PlayerModule.ControlModule)

local character = script.Parent
local rootPart = character.HumanoidRootPart
local camera = workspace.CurrentCamera

local part = Instance.new("Part")
part.Anchored = true
part.Size = Vector3.new(2, 2, 2)
part.CanCollide = false
part.CanQuery = false
part.CanTouch = false
part.Parent = workspace

runService.Heartbeat:Connect(function(deltaTime)
	local moveVector = controlModule:GetMoveVector()
	-- moveVector = camera.CFrame:VectorToWorldSpace(moveVector)
	part.Position = rootPart.Position + moveVector * 5
end)

if you uncomment moveVector = camera.CFrame:VectorToWorldSpace(moveVector) then the move vector will be in relation to the camera

2 Likes