I solved this bouncing issue by altering the value of my vertical velocity: verticalVelocity = -6.5f; and putting it inside my Update. However I only just noticed that it creates other problems, so I tried to move that line of code into my Vector3.SignedAngle code so that only when I am on an angled surface (slope), my verticalVelocity goes from its default -2f to the -6.5f shown above in order to fix bouncing. But no matter where I put it in the code below, it does not work and the velocity remains the default -2f.
// Update
RaycastHit hit;
if (controller.isGrounded && Physics.Raycast(transform.position, Vector3.down, out hit, 2f))
{
hitPointNormal = hit.normal;
float signedAngle = Vector3.SignedAngle(hit.normal, Vector3.up, transform.right);
if (signedAngle < 0.1f)
{
if (isOnAngledSurface)
{
Debug.Log("Angle <"); // moving downhill, boost speed
speed = 8f;
isOnAngledSurface = false;
}
}
if (signedAngle > 30f)
{
if (!isOnAngledSurface)
{
Debug.Log("Angle >"); // moving up hill, decrease speed
speed = 2.5f;
isOnAngledSurface = true;
}
}
}
else
{
if (isOnAngledSurface)
{
// Transitioning from angled surface to flat surface
speed = 4f;
isOnAngledSurface = false;
}
}