Hello, community.
Could you please advise me how to accomplish this task more correctly.
In the scene, there is an NPC that should approach a selected target (in my image, I’ve labeled them with red circles) if that target is approached by a player.
I see that there are two solutions.
1- Bruteforce (bad solution):
Make a set of animations (T0 → T1, T0 → T2, T0 → T3, T0 → T4, T1 → T2, T1 → T3, T1 → T4 … etc ). And run them depending on what position the NPC is currently in.
- use NavMeshAgent
Can you tell me if I understand correctly that the only correct option is to use NavMeshAgent? Or is there a better solution
Yes. Use navmesh, play walk idle-forward-run base on velocity, rotate the character according to the velocity as well.
1 Like
I would say it is depending on what else you want to achieve in your project. Is this a one of thing, kind of like a cutscene where the animation should look very on point? Then I would create a custom animation that moves the character with their rootmotion to the specific spots (I guess what you call Bruteforce).
Or is this something that you want to reuse for other situations with possible different target positions. Then definitely a movement system + separate animation system. Could be navmesh if there are obstacles to avoid or some uneven terrain. Otherwise you can just directly move the character to the positions with a Lerp for example.
1 Like