NPC walking along spline

Hi!

I’m still rather new with Blueprints in UE4. What I want to do is an NPC walking along a spline with a specific walking animation from Movement Pro. At the end he turns 90°, idles in a specific animation for a certain amount of seconds, turns another 90° and walks back. He cycles through that indefinitely, nothing more. I don’t need interaction, I don’t need any other AI capabilities.

Now, I was digging through quite an amount of tutorials already and came across a bunch of possible functionality. My problem is that I can’t filter what I need and what I don’t, as most tutorials either show how to make a playable character with Idle/Running/Jumping StateMachines, or showing way more than I’d actually need like working with Behaviour Trees and AI functions. After 5 hours of YouTube and Udemy videos I’m honestly more confused than when I started.

How do I approach this task? Which of the numerous UE4 functions (StateMachine, Blendspaces, Behaviour Trees, …) do I actually need? Any help and directions are appreciated.

Thank you very much!

My approach would be a timeline inside the NPC that controls the rotation and the position of the NPC. Each update it would update the world position and rotation of the character based on the value of the timeline and it would repeat. For animations all you really need is a 1d blend space with idle on one end and the walking animation on the other. In the anim blueprint you get the linear velocity of the character and plug it into the blend space. It is worth mentioning if you want the animation to fade in as the character speeds up you need to make the end value of the blend space the speed the character will be moving.

Thank you very much, I will try that. Two things I’m still not sure about: Do I need a blendspace for the turn as well? I have the Movement Pro pack with a 90° turn animation on RootMotion. Or I just play the animation while turning the actor? Second question: How do I distinguish between walking, turning, and standing? Do I need a state machine or is there a more straight forward way to do that as it’s strictly sequential?

If you use the method that I mentioned using velocity, the blend space would take care of the walking and standing. If you would like to use an animation for the turn as well then you would need to have the blend space inside a state machine as well as the turning animation asset. From there you would need to make a condition to play that animation when the character starts to turn. For example you can have a function in the anim blueprint that sets a variable called “turn” to true for only a split second and the condition for the turn anim would be that variable. In the character blueprint once the timeline reaches a point where the character would turn, you can cast to the anim blueprint and call that event from the character.

Thank you! I took all of that into consideration and managed to make it work. The “idle” animation in the middle isn’t there, yet, but I should be able to solve that as well. Didn’t use Blendspaces and State Machine, though, the blending is done by “Blend Pose by Int” which does the switching sufficently well.