My slope slide stops earlier than it should. This is fixed with a SphereCast, but causes other issues so I’ve tried to stick with a Raycast.
if (Physics.Raycast(transform.position, Vector3.down, out hit, 2f))
{
hitPointNormal = hit.normal;
float angle = Vector3.Angle(hitPointNormal, Vector3.up);
if (angle > 50f)
{
descendingSlope = true;
}
}
if (descendingSlope)
{
Vector3 newHitNormal = Vector3.Cross(hitPointNormal, Vector3.right);
move += new Vector3(hitPointNormal.x, -newHitNormal.y, hitPointNormal.z) * 5f;
controller.Move(move * Time.deltaTime);
}
I have tried to use Vector3.Cross and by using the cross product, try to get the real slope direction so that my player controller will finish off the rest of the slide, rather than stopping because the Raycast no longer detects a slope object. Am I way off with this? I have tried several variations but had no results, the sliding will just not work at all when I use Vector3.Cross.