Use a Raycast to get the ground normal:
if (Physics.Raycast(
transform.position,
Vector3.down,
out RaycastHit hit,
2f,
groundLayer))
{
Vector3 normal = hit.normal;
}
Project movement onto the slope:
Vector3 slopeDirection =
Vector3.ProjectOnPlane(
direction,
hit.normal
).normalized;
Slope angle:
float angle =
Vector3.Angle(
hit.normal,
Vector3.up
);