Reposition before interaction system

Hello community. I have being searching for documentation about this but no-one could help me in the forums.

I’m using the GetHitUnderCursor method to get the actor I want to interact with. My character then interacts with it. The problem is, I want my character to move towards the actor, rotate to face it, and once the movement is completed, then interact.

So far, the only solution I’ve found is through FPendingLatentAction, but I’m not entirely convinced, as it involves handling pointers with “new,” which I don’t think is what Unreal recommends doing.

I’ve been stuck on this for a week, and it’s driving me a bit crazy.

If someone could help I’ll appreciate so much.

There might be more practical solutions to this but since I’m currently unable to test it myself from my PC, the most straightforward one comes to my mind.

So you can calculate the angle between the player and the target by subtracting their locations, normalizing the result to be a unit vector and comparing it to the (x = 1, y = 0, z = 0) unit vector which you can create using the “Make Vector” node. (Because that unit vector points at the +x direction which is considered to be 0 degrees) To compare, you can use the “Delta Rotator” node to get the angle between them. Or you can simply use the “Find Look at Rotation” node and plug in both the actors’s locations, that would also work. Then, check if the player’s forward vector is also pointing at that direction by using the “== (float)” node and plug the other empty pin of that node to the z pin of the result from the delta rotator / find look at rotation. You first need to right click and split the pin to expose it’s components though, x y z won’t be visible by default. After that, you can simply bind that condition to trigger the following events. Btw you didn’t ask how to make the player face the target, right? Just in case, you can use the “Set World Rotation” node, plug in a “Finterp” node to the rotation pin, and plug in the z pin of the delta rotator / find look at rotation to the target pin of the finterp node to make it smooth.

Oh and almost forgot! For approaching the target, you’re probably using the “Simple Move to Location” node. After that’s triggered, you can call a loop that checks if the player has reached an acceptable distance from the target by again, subtracting their locations and getting the vector length.

Hope this helps! :innocent: