Double Jump Bug (Forever Jumping)

Hello Ive encountered a bug which will make the character stuck in the jump loop.

1. Character controller variant (Ultimate Character Controller, First Person Controller, etc). -> Ultimate Character Controller
2. Unity version (include which SRP, beta Unity versions aren't supported) -> 2021.3.22f1 on MacOSX with Apple Silicone

3. Bug description:
The Character gets stuck in the Jump and then is able to float over the map, if he falls down further from the jump point everything resets

4. Steps to reproduce
Enable Double Jump or go to the demo scene double jump area, use WASD to move around rapidly changing directions then spam the jump bar and soon you will find the glitch. Only happens with Double Jump and not with only normal Jumps

5. The full error message (if any)
None


I also attached a video of how this looks in the game. I would be really glad for a fix because Double Jump is an important feature in our game and it would be a shame to remove it.
 
Thanks, I'll let you know after I have a chance to reproduce this and also a fix.
 
I spent a few minutes pressing WASD but wasn't able to get the character stuck. Can you help me debug this by replacing the Jump ability with the attached file and then sending me the log output? Also, when the character gets stuck, what state is the base layer in on the animator?
 

Attachments

  • jump.unitypackage
    5.6 KB · Views: 1
Hi thanks for checking it, so that's the log:
7337 Grounded
UnityEngine.Debug:Log (object)

7409 Start Jump
UnityEngine.Debug:Log (object)

7412 Airborne Jump
UnityEngine.Debug:Log (object)

And the base layer gets stuck in DoubleJump since ability index is 1 and it only goes out of that if it's not equal 1.

Further I know this is maybe not directly related to the bug but I have more such animator bugs for example if I create a game in PUN and use the add-on the animator of the networked object will after every second respawn get stuck in Fall on the base layer also because Ability Index is set wrong. Just wanted to mention that because it's essentially the same pattern.

Hope that additional info helps :)
 
Also to avoid all interactions with any other assets I just did a clean install and only imported UCC with no add ons and plain vanilla Unity. Bug will unfortunately still reproduce. Hence maybe try spamming A and D keys more since those seem to trigger it.

Please look at the video here:
It shows everything in detail plus I kinda figured out where the problem is I think
 
Last edited:
Thanks - that helped a lot. Within Jump.OnPerformAirborneJump change the following to the OnAIrborneJump call:

Code:
                if (!m_CharacterLocomotion.Grounded) { // The character may not have left the ground before an airborne jump is requested.
                    OnAirborneJump();
                }

After this change I wasn't able to reproduce it anymore - let me know if it still occurs for you.
 
Thank you so much Justin,

Ive tried your fix and it's good but it lacks one function, the jump ability is only active until the top of the jump and once we are on the falling part it gets replaced by fall. So either you set the Jump Ability Stop Type to Manual or I would propose to change the line as follows:

if (!m_CharacterLocomotion.Grounded && IsActive) { // The character may not have left the ground before an airborne jump is requested.
OnAirborneJump();
} else {
StartAbility();
}

That way if we are past the highest point we can restart the jump ability once again. My change worked without bugs but yours also in case we change the stop type. So its really up to you which one suits you more.

Anyhow I'm really happy we got this fixed
 
So our current fix still has a bug, upon double jump there will be no surface impact because the ability stays active and wont disable as it should at the turning point.

We will also need to do the following:

In the Jump.cs in the function OnAirborneJump():

m_CharacterLocomotion.GravityAccumulation = 0;
AddJumpForce(m_AirborneJumpForce, m_AirborneJumpFrames);
m_AirborneJumpCount++;
//m_JumpTime = Time.time;

m_JumpTime needs to be commented out because we reset Jumptime but actually this shouldn't be done since we are airborne all the time right ?

If that is changed the surface impact gets played normally and also the Fall ability activates as it should I think it would be best to also include that in a future update :)
 
Thanks for digging into it. I will go with the code approach from this post. In terms of the jump time, commenting out the jump time makes sense :)
 
m_JumpTime needs to be commented out because we reset Jumptime but actually this shouldn't be done since we are airborne all the time right ?
I took a look at this again and JumpTime does need to be included in OnAirborneJump so the ability knows how long it can wait until the next jump.

Instead of commenting out the jump time you can set the InAirTime within OnAirborneJump. This was the ability can end:

Code:
            m_InAirTime = Time.time;
 
Actually right that is the more elegant solution, I just went straight for the easiest fix since I didn't fully dig into why we need m_JumpTime. But just to clarify although I believe you already found that its the condition "m_InAirTime >= m_JumpTime" which I was referring to. Hence yes "m_InAirTime = Time.time;" will be better than commenting out m_JumpTime :)
 
Top