Help with CFrame.fromMatrix and Vectors

I’m trying to calculate the plane a vehicle is currently travelling on and align it so it’s parallel to it.

Current behaviour
Everything seems to behave as expected when the Vehicle’s pitch is less than 90 degrees.

But when it surpasses that it behaves incorrectly.

How I calculate the plane

function Vector3ToPlane(VectorA, VectorB, VectorC)
	local Plane_Right, Plane_Up, Plane_Look, Plane_Center
	local VectorBC
	
	VectorBC = (VectorB + VectorC) / 2
	Plane_Center = (VectorBC + VectorA) / 2
	
	Plane_Right = (VectorB - VectorC).Unit
	Plane_Look = (VectorBC - VectorA).Unit
	Plane_Up = Plane_Right:Cross(Plane_Look).Unit
	
	return CFrame.fromMatrix(Plane_Center, Plane_Right, Plane_Up, Plane_Look)
end

The behaviour I’m trying to get

2 Likes

Your code looks perfect to me. Would you be able to share that setup you have in the video so I can mess around with it live?