Download

Pawn drifts vertically when moving relative to rotating Parent

Before I start, I apologize if this is in the wrong area of the forums. I’ve made it by so far using the results of other people’s questions without having to post myself, so I’m not super familiar with how posting works. Also sorry for the wall of text. I’ve seen a lot of people ask specific questions with little to no detail, so I want to be thorough and as accommodating as possible.

I have an issue with movement in the Pawn I’ve created. My intended result is that as a platform moves and rotates the pawn will stay in place relative to the platform and that the pawn will be able to move on relative to that platform while it is moving. I’ve created a class of Volumes which interact with the Pawn to reorient the Pawn according to the downwards vector of whichever Volume the pawn is currently inside. The Pawn is also attached as a child of whichever of these Volumes it is currently inside. As of right now, everything works fine. I can stand on the platform, and the Pawn will move and rotate with it, making it appear as if the Pawn and platform are still, but the world is spinning or moving.

However, moving the Pawn **while the platform is rotating **causes issues. Moving the Pawn in the same direction as the platform is rotating causes the Pawn to drift upwards or downwards. For example, from the perspective of the pawn, if the platform is rotating clockwise (the right of the platform is moving down, and the left side of the platform is moving up), and the pawn moves left, the pawn will drift upwards off of the platform. If the pawn moves left, they will move downwards. Without collision, the pawn would clip through the ground slowly while moving left. This issue only occurs while the platform rotates, not when the platform is translated in any direction. If the platform stops rotating after the pawn has drifted, the pawn will stop drifting and will begin to move parallel to the platform again.

The pawn uses FloatingPawnMovement to work. Initially, I was using AddMovementInput, but I changed to AddInputVector. Either way, the drifting issue was quite bad, drifting upwards about 1/2 a unit for every 1 unit of lateral movement. I tried to remedy the issue by constraining the FloatingPawnMovement to a plane which is updated every tick (not ideal) based on the parent actor (platform/volume) UpVector. This helped tremendously, but the Pawn will still move upwards or downwards with any rotation of the parent while the Pawn is moving.

I’ve included a mock-up image of what’s happening. Top left and top right of the square sections show “Before movement” and “intended result after movement”. The bottom left shows results after moving the Pawn with only AddInputVector while parented to the platform as it spins, as you can see the pawn drifts up a large amount. Bottom right shows result using plane constraints along with parallel movement vectors which update each frame based on the Parent Actor’s current UpVector, as you can see the issue does not go away, but it is decreased.

What I think is happening, is that the information that the Pawn receives when it is looking for its Parent Actor’s UpVector each tick is outdated, resulting in the Pawn being constrained or moving along a vector which used to be parallel to the platform, but the platform has since moved, resulting in what looks like the Pawn moving into or away from the platform.

I’ve also tried using physics, but physics movement on a moving object has ended up being pretty janky each time I try to tackle this issue from that angle.

Let me know if more information is necessary, and thank you for any help or suggestions!