I have my own C++ class derived from APawn.
This class is reading input from axis to actually move itself on a plane.
The movement isn’t being done with a MovementComponent but with a custom method inside the pawn itself. I keep track of the velocity based on the input and move it accordingly.
The weird thing is that when I stop all inputs I see that my velocity is back to zero, but the pawn keeps moving like if inertia was applied. Is there any default component that might be interfering in any way?
Since I actually move the pawn only when the velocity is over zero, it shouldn’t move.
Any clues at where to look at?
Physics are disabled on the Sprite (the pawn contains a paper2dsprite and two boxcomponent) and on the two box components. Maybe there’s another option to check or a hidden component? Might it be something set in the tilemap’s components?
Is it possible that your velocity isnt exactly zero? Typically you would check to see if its nearly zero within a small amount. Reason I ask is that its possible the inputs arnt exactly zero depending on input method (analog) and it does sound like a possible rounding issue.
MoveH and MoveV simply move the sprite the amount passed checking if there’s a collision in between with simple overlap checks. I move the actor in the new position, check for collision and if it collides I move it back to the original position. Rinse and repeat.
The Velocity.X becomes zero as soon as I stop pressing the left or right key, but the pawn keeps moving. I exposed the value so that I can see it changing in the editor and it’s exactly zero when it still moves. There’s no fractions or rounding errors apparently.
I even added actions instead of axis as input types to make sure the value is either one or zero. I’m 100% sure it’s exactly zero. And since the pawn keeps moving even faster than it should, I’m pretty sure there’s some physics stuff going on, but I can’t understand what and where