Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Coyote Time Not Functioning Properly

Discussion in 'Physics' started by zaidan1193, May 18, 2022.

  1. zaidan1193

    zaidan1193

    Joined:
    May 1, 2022
    Posts:
    2
    So, I've coded in this simple code to implement coyote time. However, I've been getting this bug which causes my player to double jump, I've been trying to fix it for the last few hours and I still have no clue what to do.
    Code (CSharp):
    1.         if(Input.GetKeyDown(_inputManager.jumpKey)){
    2.             _jumpBufferValue = _jumpBuffer;
    3.         }
    4.         if(_jumpBufferValue > 0 && _coyoteTimeValue > 0){
    5.             _jumpBufferValue = 0f;
    6.             _coyoteTimeValue = 0f;
    7.             Jump();
    8.         }
    9. //////////////////////////////////
    10.         if(_isGrounded){
    11.             _coyoteTimeValue = _coyoteTime;
    12.         }
    13.         if(!_isGrounded){
    14.             _jumpBufferValue -= Time.deltaTime;
    15.             _coyoteTimeValue -= Time.deltaTime;
    16.         }
    I've tried setting the coyote time to 0 but it is still not working, anyway thanks!
     
  2. zaidan1193

    zaidan1193

    Joined:
    May 1, 2022
    Posts:
    2
    The Isgrounded and !isgrounded are in the fixedupdate function while the ones that detect input are in the update function.