Context
CharacterMovementComponent can be set in the NavWalking mode so that on the server the characters move using the navigation mesh as floor. This helps performance when the nav mesh is more coarse than the complex geometry.
On the client the characters do move on the real floor geometry. A configurable tolerance 'UCharacterMovementComponent::NavWalkFloorDistTolerance' exists so that the character on the server and client can be at different heights, as long as it's below that error.
Characters can also crouch and uncrouch, at which point their capsule half height changes. If bCrouchMaintainsBaseLocation is true, the capsule is teleported downwards on crouch so that the feet stay at the same location.
The downward teleportation would normally trigger the character mesh to smooth towards the new capsule location. This is triggered via UCharacterMovementComponent::SmoothCorrection() initializing smoothing values. Because we don't want the character to actually smooth when crouching or uncrouching, UCharacterMovementComponent::Crouch()/UnCrouch() apply an offset to the current smoothing state of the character, specifically to ClientData->MeshTranslationOffset (current interp location) and OriginalMeshTranslationOffset (start of interp location).
Problem
This problem is easier reproduced with high values for NavWalkingFloorDistTolerance (if the project has a deliberately coarse nav mesh) whose Z is often not accurate to the floor geometry.
The capsule resize on crouch always triggers UCharacterMovementComponent::SmoothCorrection() due to the capsule having teleported.
UCharacterMovementComponent::Crouch() assumes that SmoothCorrection() has started smoothing due to a height offset and finishes it immediately by applying an inverse height offset. However, a NavWalking character will have a tolerance 'NavWalkingFloorDistTolerance' before initiating character mesh smoothing. When the distance traveled in Z by crouching is less than that, no mesh smoothing occurs but UCharacterMovementComponent::Crouch() still tries to counteract it by offsetting the mesh location. This causes characters to move upward when crouching (Crouch() assumed SmoothCorrection() moved it downward, and vice versa when uncrouching.
On the client this shows characters being temporarily higher and lower when transitioning between crouched and uncrouched.
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-231679 in the post.
0 |
Component | UE - AI - Navigation |
---|---|
Affects Versions | 5.4, 5.5 |
Target Fix | 5.6 |
Created | Nov 27, 2024 |
---|---|
Updated | Dec 11, 2024 |