I made a character controller and I’m trying to make slope movement smoother.
One way to do this is to rotate the move direction to the normal of the slope your standing on.
Iv done this in Unity before and its rather simple there. But on roblox i have no idea how to do this.
Should be able to pull it off like this. There are simpler ways, but this is the ‘correct’ way which guarantees there won’t be any ambiguity.
local base = starting_cframe
-- Change this next line to whatever position you want 'rotated_cframe' to be at.
-- If you just want it to be zero so that 'rotated_cframe' is rotation only, set it to
-- Vector3.zero
-- I started it at starting_cframe.Position so that you can specify starting_cframe
-- and just rotate it in place how you need it.
local rotated_pos = base.Position
local y_vector = slope_surface_normal
local x_vector = base.LookVector:Cross(y_vector).Unit
local z_vector = base.RightVector:Cross(y_vector).Unit
rotated_cframe = CFrame.fromMatrix(rotated_pos, x_vector, y_vector, z_vector)