DeprojectMousePositionToWorld position offset when moving

Hello everyone!

I’m doing a top down game that is supposed to have controls and camera movements similar to those of darkwoods, an awesome game made on Unity.

In order to do that I wanted to debug the detection of my mouse ( I’ll deal later with simulating a mouse with a gamepad if needed be )

So I did a little function that is very simple in the tick of my Controller:

And it works fine… Unless I move with wasd… As you can see here on this top down view of my debug cube character:

I noticed that it seemed that the offset was caused by the player velocity. I tried a garbage fix (which you can see commented in my code above) to get my input values and add them to the X and Y of my cursor. It did fix it somewhat but it’s not perfect and it’s a garbage fix anyway.

I have tried to mess with the tick group as well, thinking that maybe I should update my controller after the physic or my pawn, or my camera. But it didn’t work.

I have some extreme solutions if needed. Like I could attach a plane to the pawn and use GetHitResultUnderCursor controller function. This may work. But I think it’s overkill. Why can’t I just get my cursor position in world on the near camera clip plane in real time? It would ask less computation.

I could also just set my mouse cursor to zero and record the delta to update it and move my aim sight accordingly. That would be ok… But it would make me avoid unreal’s Gameplay Framework. And I want to work with unreal, not against it or bear with it. Actually take what it provides me and use it in a good way.

If I ever find a solution by myself, I’ll let you guys know. Thank you for ready all that and for your attention.
Lot of love to anyone willing to help!

I used a new solution and used the function GetHitResultUnderCursor and watched the WorldStatic collision channel. It works but there is still an issue that I think would never be seen but there is still an 1 pixel offest when I move.

I think it is due to the fact that my movements might be a bit weird for Unreal : I use a capsule collider as the root component and use override its velocity for movement.

Player collision is my capsule collider component and PlayerVelocity are my axis inputs.

I will try to do movement setting the pawn location and trying to find actual movement functions and see if it fixes it. I might lose a bit of time as this 1 pixel offset is not a big deal. But still I want to understand what is happening… Even though changing the tick group should have fixed that… We’ll see.