Search Unity

Bug Normal angle on the floor is not at 0

Discussion in 'Documentation' started by youlanneju, Mar 9, 2022.

  1. youlanneju

    youlanneju

    Joined:
    Aug 19, 2020
    Posts:
    4
    Hi,

    I would like to know why my Raycast return values from 50 to 80 when I'm raycasting with this method :

    Code (CSharp):
    1.  
    2. private bool IsSliding
    3.     {
    4.         get
    5.         {
    6.             if(IsGrounded() && Physics.Raycast(transform.position, Vector3.down, out RaycastHit slopeHit, 7.5f))
    7.             {
    8.            
    9.                 hitPointNormal = slopeHit.normal;
    10.                 return Vector3.Angle(hitPointNormal, Vector3.up) > GetComponent<CharacterController>().slopeLimit;
    11.             }
    12.             else
    13.             {
    14.                 return false;
    15.             }
    16.         }
    17.     }

    I placed a character controller and a box collider that is trigger-checked.

    For the floor, right now, I have a stretched cube as a test zone. (I tried also with a terrain, with no floor elevation and the results are the same)
    So, when I'm trying to make my character slides on slopes, he slides on every part of the map except the slopes (from little to high) because he detected the angle of the slope normally. (Like a 10 angle slope is detected at an angle of 10)

    Here is the code when the character needs to be moved on slides :

    Code (CSharp):
    1. if (IsSliding)
    2.         {
    3.             Debug.Log("IsSliding");
    4.             controller.Move(new Vector3(hitPointNormal.x, -hitPointNormal.y, hitPointNormal.z) * slopeSpeed);
    5.         }
    I already post this on another part of the forum, but not in the bug section, here is additional Infos :
    - The version that I'm using is Unity 2020.3.30f1
    - Here is a link to the thread that I originally make : https://forum.unity.com/threads/normal-angle-on-the-floor-is-not-0.1247596/