Push the player to the right or left of a wall depending on which way he is moving.

Hello! I’m just going to start by saying that I am super tired from programming today so if what I say makes no sense please tell me.

So I am working on a project where you as the player will fly around like in a glider or an airplane. And right now I am trying to implement a “push” function that will push the player away from a wall if he is trying to fly straight into it.

My method so far is to use a ray-trace that shoots a straight line ahead of the player and if it collides with a wall the player’s plane will start rotating on the yaw away from the wall. The problem I am having is determining if the player should be pushed to the left or right. What I want to happen is that if the player is rotating on the yaw to the right he will be pushed to the right and vice versa and I cannot for the life of me do the required math to determine which way he should be pushed.

What I want to have (or thinking that it should work at least) is to somehow just make moving straight ahead an angle or point of zero and moving to the left will provide a negative value, while moving to the right produces a positive value. Then use these values to push the player in the right direction. But my math just dosen’t seem to be working.

I am extremely grateful if anyone has a solution for my problem, and again if my explanation don’t make any sense just tell me and I will try to explain in a better way.

Okay Nevermind I solved it!

I’m not sure how it works with uploading blueprint pictures here, but I made it through blueprints for now, although it is easily converted to c++ code so if anyone is interested or has similar problems this is how I solved my problem:

What I found was that if I did a cross-product between the actor forward vector and the impact normal. The Z-value would represent a positive or negative value depending on the angle that the player was facing towards the wall, which was pretty much exactly what I needed.