# Check which direction the player was hit from?

This has proven to be a real head scratcher since I am so close, but Unreal’s strange -180 to 180 degree rotation system is really throwing a wrench in the works.

I have made a wall running mechanic, but I want to figure out which way to lean the camera while wall running. (For game feel)

Literally all I need to do is use the information from my “Hit” event node to figure out which side of the player the wall is one (Left or Right).

It really is that simple, but I am having so much trouble with this. I thought the obvious answer would be to take the Normal rotation of the wall surface, and then subtract the player rotation, and boom. I would have a Rotator that I can use to pinpoint exactly on which side the player was hit. But the rotation system really gets in the way of this.

Does anyone have any other methods? (Cheers)!

Don’t try subtracting rotations, that won’t do you any good.

What I came up with from the top of my head is this:

In this case when the Character is hit from the left, the value will be positive, is from the right — negative, both within (0,180).
Hope that helps.
3 Likes

Hi Tuerer, Thanks for the response.

Could you give me a quick explanation on what some of these nodes are doing? Just for my own benefit and understanding my code will help me on this project down the line.

Namely the “dot” and “ASINd” nodes.

These are just common mathematical functions, I don’t think I can explain it better than the Wikipedia can.

Dot product - Wikipedia

Inverse trigonometric functions - Wikipedia

Edtd: Basically these two nodes together return the angle between two vectors.

Okay, I finally got my head around the nodes. I didn’t find the Wikipedia pages as much help since they are extremely comprehensive.

But for anyone else: from what I gathered, the Dot, node compares the similarities between two vectors on a range from -1 to 1. Specifically as normal directions.

Then the ASINd converts them to degrees. But, for my case anyway, Dot was all I required to get the results I needed.

it should be ACOSd, not ASINd.

dot product multiplies each one then adds them
Where [5,2,1] and [6,4,3] are multiplied like so:
(56)+(24)+(1*3) = 30 + 8 + 3 = 41