Search code examples
unreal-engine4unreal-blueprint

AddImpulse function with relation to player's view on Unreal Engine 4


Me and my friend are very new to UE4, and we are are trying to develop a game where your main method of movement is your gun's recoil.

We are having a lot of trouble adding impulse relative to where the player shoots, since the AddImpulse function seems to work relative to the world (So the player will always go in one direction, no matter where he is looking at when he shoots).

If anyone has any idea on how to make the AddImpulse function add an impulse in the opposite way of the player's view it would be of great help!


Solution

  • I figured it out after some frustration and help from the UE4 subreddit. Use the getworldrotation function for the camera, then multiply that by how much impulse you want and feed it into the AddImpulse function.