Redirecting pawn movement based on a normal

Hey guys,

I’m implementing an RTS camera. My problem is that I want to implement map boundaries, but I do not want to use Camera Blocking Volumes since I want to be able to rotate and zoom even if the bounds are reached. And for some reason when I use regular Blocking Volumes to restrict the pawn, the capsule just gets stuck into the volume and can’t move along the volume. It can only move back to get unstuck. So I can’t get that sliding along the bounds feeling that I want.

So that’s why I wanted to code my own collision with overlap events. I got things working but I just can’t figure out the math here.

Here, Cyan is the Impact Normal from the sweep, Yellow is my Actor Forward Vector, and Magenta is my Actor Right Vector. I guess I suck at math, because for the life of me I can’t understand what to do to restrict Pawn’s movement towards the reverse of the Impact Normal only, but allow it to move along the wall.

So if anyone can point me in the right direction, I’d compose a sonnet for them…

Okay for all those who stumble upon this, I found it. What you’re looking for is to project the impact normal to the forward and right vectors, which gives you the normal vector in terms of those vectors and then you can sneak those values however you want into your movement script. FVector and KismetMathLibrary both have functions for this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.