[Bug] Grounding on moving platforms that are moving up

lazylukey

New member
1. Character controller variant: Third Person Controller (3.0.18)
2. Unity version: 2022.3.13f1 URP
3. Bug description: Jumping onto a moving platform that is moving upwards can cause character to remain in Fall ability / not become grounded
4. Steps to reproduce: It's a little tricky but the easiest way is to create 2 or more moving platforms that go up slowly that are you able to jump between. You can have them come down very quickly using states. Eventually and it doesn't take much effort, the character will get stuck in an ungrounded state as long as you keeping feeding in movement (i.e. WSAD).
5. The full error message: N/A

Here's a video of the bug: Screenshot of a moving platform's settings:
Distance between the waypoints is 111m. Slow state sets 0.05. Speed up sets 10 (just to come down fast)

We have already made a fix to CharacterLomotion.cs that seems to fix it so we'd like some feedback on whether its a good fix or not:

Line 1239:

C#:
grounded = !m_ForceUngrounded && (stickyGround || localDesiredMovement.y <= Mathf.Abs(distance) || (closestRaycastHit.transform.gameObject.layer == LayerManager.MovingPlatform && distance < m_SkinWidth)) && ((Mathf.Abs(localDesiredMovement.y) + (stickyGround ? (m_StickToGroundDistance + c_ColliderSpacing) : 0) > distance) || distance < m_SkinWidth) && (distance + Mathf.Min(localDesiredMovement.y, 0) <= m_SkinWidth || stickyGround);

The check for the closest raycast hit layer being MovingPlatform and if distance is less than skin width proceed to next &&.

Thanks!
 
Thanks for debugging. At the surface that change looks good and I'll take a closer look at it for the next update.
 
After looking into this more I changed that grounded line to something a bit more versatile:

Code:
grounded = !m_ForceUngrounded && (stickyGround || localDesiredMovement.y <= Mathf.Abs(distance) || (m_MovingPlatform == closestRaycastHit.transform && distance < m_SkinWidth)) && ((Mathf.Abs(localDesiredMovement.y) + (stickyGround ? (m_StickToGroundDistance + c_ColliderSpacing) : 0) > distance) || distance < m_SkinWidth) && (distance + Mathf.Min(localDesiredMovement.y, 0) <= m_SkinWidth || stickyGround);
 
Oh I gave that new line a test and I could reproduce the issue with it, I'm guessing because m_MovingPlatform isn't necessarily set in the case where it hasn't successfully grounded?
 
Hi, we found an issue with jumping on a moving platform that is moving up at very high speed. The player basically slips through the moving platform and is then flung into space with seemingly infinite velocity.

Here is a video: https://streamable.com/ndjr32
 
I will merge this with your other platform thread since it's probably related. Can you send a small repro scene to support@opsive.com that shows the issue from a fresh project so I can take a closer look? If you can include multiple platforms for the original issue as well that would be great.
 
Top