Download

How to get the correct location on a component?

Please note: I am using UE4 Version 4.5.1, please take that into consideration. No it cannot be changed.

Okay, so lets imagine we have a simple rectangle as a wall. Its about 3 times higher than our player.

I want to bounce actors off the wall that touch it, no matter where they hit on the wall, I want to shove them backwards.

So for this, originally the graph looked something like this:

original_logic.JPG

The problem is that if the player moves backwards into the component, it will knock them THROUGH the actor instead of backwards.
I need to get the correct location on the bottom half of that equation to multiply.

So now I have tried 2 alternatives:

(1) I can closer if I make a vector from the X & Y of the origin of the component and the Z of the player, but it doesn’t quite shove back, it shoves from the center of the rectangle based on the Z of the player.
(2) I went to try to cast the players location on to the plane of the component. Having some issues doing this though. Below is my current graph. The Get Direction Vector out pin goes where the Get Actor Forward Vector was connected to in the graph above. The issue I’m having with this one is that the plane is not in the right place. Its mirroring the actor correctly but just not on the actual component.

plane_vector.JPG