Hello guys. I’m very new to C++ and only know the basics. Most of what I know about Movement Components is what I’ve understood reading through ProjectileMovementComponent.cpp, FloatingPawnMovement.cpp and CharacterMovementComponent.cpp in the source code of Unreal. I’ve also been reading the documentation pages of functions such as “SlideAlongSurface” and “SafeMoveUpdatedComponent”. So I’ve started to make my own Movement Component and through trial and error I think I’ve started to understand the rough basics of how they work.
But my novice understanding of how these systems work have left me unable to fix the current bug/problem I’m having.
There seems to be a stutter in the velocity whenever my pawn’s capsule collision rubs against a wall.
Here’s a video demonstrating my problem:
It might be a little hard to see but the pawn jolts backwards and to the side randomly while I walk along a wall.
The Movement Component (Stub01MovementComponent) is currently just a modified version of Floating Pawn Movement without the checks for WorldBounds and if the player is AI or LocalController:
The movement is created in blueprint by adding a new velocity to the current velocity and setting that velocity as the new velocity of the Movement Component:
Calculations of Gravity, Forward Movement, Right Movement, Friction, WallRun, Etc… is done in separate functions that I plan on porting from Blueprint to C++ functions once I’m happy with them:
But back to the problem at hand, the velocity stuttering. I’ve tested all of my blueprint functions for calculating the velocities and displayed them on my debugHud while playing to see if the changed during the stuttering. The only thing to change in sync with the stutter was the friction. So I removed the friction function and tested again, but the stutter were still happening. This left me scratching my head since all the other velocity variables did not show any sign of the stutter, yet the actual velocity of the Movement Component still showed stuttering. The “aha!” moment came when I realized that my blueprint functions was just adding velocity to the stutter, and not the cause of the stutter itself.
This led me to believe that the stutter was a problem with the Movement Component itself.
I tried my usual trial and error method again by commenting out these two lines in the code:
This seemed to fix the walk along wall stutter, but now the player’s collision would stutter and get stuck. The velocity also behaved differently with the player not keeping his momentum properly:
Here’s another video showing the same situations with the original component without the two lines commented out:
So with this explanation I hope that some of you can help me figure out a solution to this. Also does anyone have any good recommendations for resources where I can learn more about how to make my own Movement Component? Clueless trial and error can only get me so far:P
Thanks for your time!