Movement with Animation: Character vs Pawn vs Actor

I have data for an actors movement which is being read in from a file at the start of the game. The data that gets read in contains Vector positions where the Actor should move to next. I currently have the Actor moving from Position to Position no problem… until I start to add animation to a Skeletal Mesh attached to the Actor.

My problem: How can I found out the velocity to work out which animation to play idle, walk, jog and running? It currently doesnt have a velocity as i am lerping the position:

SetActorLocation(FMath::Lerp(GetActorLocation(), newPos, 0.01));

Any thoughts on how to set the right animation based on distance travel and speed?

Should I move my Actors movement to Character so I can use AddMovementInput to get velocity. Then, If i go down that route, how to I say:

Move this character from my current position, to my next position in X amount of time giving the character the correct velocity to use in the animation selection.

You should use a velocity to update the character movement, not the other way around, so for movement you want to move the character like: (GetActorLocation() + (Velocity*DeltaTime))

If you really want to calculate a velocity from the current movement, which is kind of backwards, you can use: (PositionThisFrame - PositionLastFrame) / DeltaTime

Good luck :slight_smile:

Thanks for the reply.
I’m using an actor now and calculating the velocity, new location, rotation and everything else myself :slight_smile:
Pretty similar to the method you described :slight_smile: