Need help to get player to face enemy when attacking
So i am trying to make my player face enemy while attacking and to only face enemy when in range can anyone help ?
asked Mar 28 '17 at 11:14 PM in Blueprint Scripting
First, if your Player Character uses an AI Controller and a Behavior Tree, you can use "Rotate to face BB entry" node and entry should be current enemy.
If Player Character is not using Behavior Tree, simply get Enemy location and Player location, then use "Find Look At rotation" when start is player location and end is enemy location.
Then, set player's world location to be the result of Find Look At Rotation (or only the Z value of it, to only make it rotate on the Z axis making it only "face" enemy).
All the best
EDIT FOR EXAMPLE: The code is inside Player Character blueprint.
Here is a simulation:
If you calculate
You can also check the length of this vector to get the distance the player has to the enemy, and if it is too big, not apply the rotation.
answered Mar 29 '17 at 07:30 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here