Hi,
Long time ago I went through this problem and my solution was to get the playermodule, get the controls and get the move vector of the player from controls like PlayerModule:GetControls:GetMoveVector… Don’t ask me why I don’t want to use the player module…
But now I want to find out how to find the relative direction without using robloxs playermodule…
Here’s my current script and my attempt:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Knit = require(ReplicatedStorage.Packages.Knit)
local ContextActionUtility = require(ReplicatedStorage.Sources.Utility.ContextActionUtility)
local waitForChildWhichIsA = require(ReplicatedStorage.Sources.Utility.waitForChildWhichIsA)
-- Variables
local Player = game:GetService("Players").LocalPlayer
local Character = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
-- Controller
local Movement = Knit.CreateController{
Name = "Movement"
}
local Directions = {
[Vector3.new(0, 0, 0)] = "Not Moving";
[Vector3.new(0, 0, -1)] = "Foward";
[Vector3.new(0, 0, 1)] = "Backward";
[Vector3.new(-1, 0, 0)] = "Left";
[Vector3.new(1, 0, 0)] = "Right";
[Vector3.new(-1, 0, -1)] = "FowardLeft";
[Vector3.new(1, 0, -1)] = "FowardRight";
[Vector3.new(-1, 0, 1)] = "BackwardLeft";
[Vector3.new(1, 0, 1)] = "BackwardRight";
}
function onDirection()
local RelativeDirection = workspace.CurrentCamera.CFrame:VectorToObjectSpace(Humanoid.MoveDirection)
local Direction = Vector3.new(
math.round(RelativeDirection.X),
math.round(RelativeDirection.Y),
math.round(RelativeDirection.Z)
)
print(Directions[Direction], Directions[RelativeDirection])
end
Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(onDirection)
return Movement