Angle between pawn and closest point on collision help


Hoping someone may be able to help with something I thought would be simple, I feel I’m missing something obvious.

I’m trying to get the angle between the ClosestPointOnCollision and the controlled Pawns location, however when the pawn is in front of the collision point I expect it to be 0 degrees, but it’s not. Instead it varies from 0-20 degrees as I move left & right in front of the collision component, despite still being in front of the collision point. The amount of variation changes with size/width of the collision box shape.

I’ve attached images where I’m:

  • fully on the right of the collision component (shows around 0 degrees)
  • In the centre of the collision component (shows around 10 degrees)
  • fully on the left of the collision component (shows around 20 degrees)

The drawn box is the collision component, the drawn white sphere is the point returned by ClosestCollisionPoint on the component. I’ve attached the BP of the set up also.

I’ve also tried just using the owning actor location and the pawn, but get a similar thing where i’m not nearly at 0 degrees when in front of the centre of the actor.

The actor is just a scene component as root with a box collision attached.


Must admit, I don’t quite get the pawn setup, but it doesn’t matter.

If you could make another debug point ( like your white sphere there ), which is just the pawn location ).

When you get collision, press F8 and take a look at what’s going on from above.

It’s unclear what you are trying to do.

Those are two points in the world, they are relative to the world origin, getting their relative angle wouldn’t make much sense.

In your blueprint, you are getting the (PointOnBody - PawnLocation) vector, which is probably one right piece of the puzzle. But you are comparing that to the world position of PointOnBody, which doesn’t make much sense either :

What exactly are you trying to achieve ?
Compare that vector to the pawn rotation ?
Compare that vector to the normal of the body surface on the point ?
Those are the only two cases I can think of that would return zero like you expect.

Ah thanks, clearly misunderstanding vectors, and world/local space.

I’d like to get the angle between the Normal to the PointOnBody and the PointOnBody - PawnLoc vector.

I’m not too sure how to get the normal to the PointOnBody if you have suggestions?
Will I need to find the relevant vectors myself and take cross product or is there an easier way in Unreal?

I tried using the FindLookAtRotation and that gives a much better representation of what I’m after, but I’d like to understand why & where I’m going wrong with the above