I’m making R6 Strafing animate script made by me, what I’m trying to do is get the direction the player is walking either straight or diagonally, for example:
LeftFront, Front, RightFront, Right, RightBack, Back, LeftBack, Left.
The problem is that I don’t have the “formula” to get the diagonal direction, I tried in various ways, but none of it worked out because I’m a little too stupid for angles.
I’m trying to get it out of the relative direction of the HumanoidRootPart
Extremely late, but you can get the humanoid’s MoveDirection, it returns a Vector3 value (as I believe), and you can get what direction they’re walking in.
You can actually get the direction in several ways, I have tried 3 methods since not long ago I was recreating the movement system of Quake and CS:GO in Roblox with LinearVelocity, but this same one is not made with the Roblox humanoid.
Method 1: With Humanoid
In fact If your movement system uses Humanoid you can use this method:
function getMoveDirection( humanoid: Humanoid, rootPart: BasePart ) : Vector3
local forward_direction = rootPart.CFrame.LookVector;
local right_direction = rootPart.CFrame.RightVector;
local wishdir = forward_direction * humanoid.MoveDirection.Z + right_direction * humanoid.MoveDirection.X;
return wishdir.Unit;
end;
local wishdir = getMoveDirection( humanoid, rootPart );
Method 2: With LinearVelocity
If you use LinearVelocity you can simply get the direction of the vectors in the “VectorVelocity” property.
Method 3: Only RootPart, Custom Movement System
Thanks to the lookVector you can obtain the direction in which the player is looking based on your personalized movement system.