Heya there, so in the project I’m working on I want to have sideway movement.
So the way I’m thinking I want it to be is I have 2 points/parts that the player can walk between, and based on these points calculate the way the player should be positioned to be sideways.
As a starting point, how would I achieve this? I have more thing I would like to add, but I need to have some sort of base first.
From what I understand given two vectors you want to produce a CFrame positioned at the start point with its right vector facing the end point to make the character look left. If you want the character to look to the right, then you need to multiply the right vector by -1.
local function getSidewaysCFrame(startPoint: Vector3, endPoint: Vector3, isFacingLeft: boolean) : CFrame
local direction = if isFacingLeft then 1 else -1
local difference = endPoint - startPoint
return CFrame.fromMatrix(difference.Unit * direction, Vector3.yAxis) -- we don’t need to include the third (optional) argument bc fromMatrix automatically calculates the lookVector
end
Nope, I wanted to be able to make sort of a “movement axis”, to restrict player movement from left to right in that movement axis and only let the player move left and right for a sideway movement.
I’ve already done it though so I don’t need any help, thanks though!