How to make a walking dinosaur follow a Spline Track?

How can I efficiently make an animated character follow a Spline Track, so that a non-playable character moves forward when there is a walking animation playing, and is standing still when an idle animation is playing?

Hej! That’s my question in short! I’m completely new to game development and I feel like I’m doing a lot more work then I need to do, so I thought I’d show a bit of my progress and maybe get some tips on how to do it quicker in the future. This is my first project in Unreal Engine (5), and, so far, I’ve programmed everything with Blueprints.

I’m currently working on a project that I would describe as an interactive dinosaur documentary, where the player walks around during the age of the dinosaurs, and is informed by a narrator whenever they get close to a dinosaur. Just like in a documentary, there is a narrator and an informative environment, but unlike a documentary, in my game you can choose which dinosaurs you want to hear about, so you can basically skip the boring parts.

Naturally, I’m going to need a dinosaur that follows a path and shows a bit of their daily routine. The best way to do that, I thought, was by creating a Spline Track. For that, I followed this tutorial: Ue4 Tutorial - Moving an Object along a path using a Spline Track - YouTube

However, for a naturalistic touch, the dinosaur also needs to stop moving occasionally. I did this by keeping the position the same on the timeline of the Spline Track, and thus turning the velocity to 0 u/s. This worked, but was an extremely time-consuming job, since I had to match the timing of the timeline exactly with the timing of my animations. On top of that, I manually calculated the new distance for the Spline Track after every period of walking by multiplying the speed with the time the animations took.

I guess what I really want to know is; is there a way to make an NPC move with a constant speed, whenever a certain animation is played? So that, for example, after every step, the dinosaur walks two units.

Since you stated that you’re new to game development, let me offer you a different way of doing this. You write:

A lot of the time, this is not the best way to go about it. You want a walking animation to play when the character is moving and an idle animation to play when standing still. Let movement drive animation, not the other way around. There are tons and tons of tutorials about how to do that, including in the official docs.

I would also ditch the spline track for a simple waypoint system, especially as it seems to be starting to become inconvenient already. You place the waypoints wherever you want throughout your level and let your character move from one to the next.

Add two variables to the waypoint Blueprint. One references the next waypoint on the path, the other how long to linger at the current waypoint before moving on to the next. Super simple, easy to tweak, and probably good enough for what you want for now.

You don’t have to use a spline to “stick” stuff to.

You can derive locations as waypoints to use for a nav invoker with the functions it provides.

Splines are 100% the best way to make pathways for stuff to follow.
Roads, walkways, rivers.

Almost all of them are made with a spline regardless. So having the ability to take that same spline and say “follow this” isn’t something to balk at.

The “proper” way to do it for an NPC would be by creating an AI blackboard that reads a point and adjust the move to command accordingly.

The proper way to do it for a PC - and as an example you can maybe take red dead redemption horse riding with the follow camera function - is to add movement input along the spline.

The proper way to do it with floating objects is to just use a flow map system - mind you, the construction is usually still spline bound, but the object doesn’t care about the spline in this one case.

The subject overall can be a book in itself, but if you look up AI blackboard and NavInvoker you should be able to get started.