Good afternoon!
There was a problem with turning opponents in my project. Say, when hitting them from the back, I need them to turn smoothly towards me, while playing the animation of the turn until they look exactly at me.
What is the best way to implement this mechanism? Checking the angle for each tick? Or are there any more concise and thoughtful solutions?
The same goes for the usual movement of opponents when they randomly move around the level. From time to time they get a random point around them that needs to be moved. So, before starting to move to this point, they first need to turn in its direction, and only then start moving.
If you briefly describe the question, you get the following:
What is the best way to check if the NPC is looking in the right direction and if not, how can I turn it so that it looks there? Of course, all this must be accompanied by animations.
P.S. There is a set of animations, you just cannot use it for its intended purpose.
What you need is AI Behavior Tree just google it, it uses NavMesh for navigation and rotation. The animations will work automatically if you give them the correct variables such as velocity (there lots of animation tutorials for that from UE4 YouTube channel). Oh and never use tick for animation or Npc behavior suggest only to have one or two actors on the whole map that using tick. Good luck.
I can work with the Behavior Tree and animations, the only question is how to check that the character is currently turning? I have two variables: direction and speed. With their help, I can find out where the character is going and at what speed, but I don’t know how to know the amount of turn the character will make before starting to move towards the goal.
The character will start to rotate immediately as soon as it will start moving with NavMesh unless you give it a different behavior in Behavior Tree, the speed can be found in PawnMovement or CharcterMovement if not mistaken its called RotationRate
Apparently I’m setting the Animation Blueprint incorrectly, because I can’t correctly add rotation animations to my opponents. I hope that I will clearly explain the essence of the problem (forgive me my English), but the NavMesh operation does not cause any complaints and the characters rotate correctly and the rotation rate is correct, but I do not know how to accompany the whole procedure with animations that are not included in Blendspace.
Sorry, I am a little bit confused here, do you want to drop a few screenshots and show me what you want?