Distance Matching Locomotion : Giving it a shot!

Awww private messages that makes me sad, why not just share here so we can learn too but its all good this is what im doing to predict my stop location then i convert it to frames and pick the appropriate frame to play the stop anim :slight_smile: not saying it gonna work for everyone but this is something basic to start off. Cheers!

@dandezign Hi man! Thanks for sharing your approach!

no doubt man thats why this community exist to help each other. :wink:

1 Like

Does anyone know what is going on with animation when I turn on the slomo mode?

BlendSettings.png

The snapping Could be due to the blend time between animationsā€¦ if itā€™s set to 0.

Holy ā– ā– ā– ā– ! Root cause of my problem was I forgot to prevent set up StopAnimPosition = 0 and Infinity values from my GetCurveTime function :smiley:

I fixed the GetCurveTime function, but animation blending and transition rules still need more polishing.

@dandezign Hi! Can you share your CharacterMovement settings? I want to try your prediction function, because my function doesnā€™t consider the ground friction parameters.

P.S.: Can you show us your solution on video? :slight_smile: Thanks in advance!

How do you guys using DistanceCurve? SqeuneceEvaluator node takes the time of curve, not a distanceā€¦

I caculated start/stop movement pivot, so I have a distance to start/stop point. But I can figure out how to relate position data to time. :frowning:

Specifically, remaining distance to stop pivot at this frame does not always match curve key at time t. Maybe should I find time by value at range PreviousDistance, CurrentDistance)?

Edit: @ prediction based on physics was really inaccurate(because UCharacterMovementā€™s velocity calculation heaily depends on DeltaTime), so I simulated UCharacterMovementComponent::CalcVelocity in my function.

@dragon-kurve You should use FAnimCurveBufferAccess but itā€™s work only with curves compressed via ā€œUniform Indexableā€, then you can get times and values by sample index. You should search nearest distance in this values and then get corresponding time value by it index.


FSmartName CurveSmartName;
AnimationSequence->GetSkeleton()->GetSmartNameByName(USkeleton::AnimCurveMappingName, CurveName, CurveSmartName);

FAnimCurveBufferAccess CurveBuffer = FAnimCurveBufferAccess(AnimationSequence, CurveSmartName.UID);

What do you mean about simulating CalcVelocity? Can you show it or describe?

@ Itā€™s fairly simple.



// in my UCharacterMovementComponent subclass

FVector PredictionVelocity = Velocity;
FVector PredictionLocation = UpdatedComponent->GetComponentLocation();

float PredictionTime = 0.0f;
while (PredictionTime < MaxPredictionTime) // MaxPredictionTime is 2.0f in my case
{
    PredictionVelocity -= (Friction * PredictionVelocity + Deceleration) * PredictionTimeStep; // PredictionTimeStep is 0.02f in my case
    if (FVector::DotProduct(PredictionVelocity, Velocity) <= 0.0f)
    {
        break;
    }

    PredictionLocation += PredictionVelocity * PredictionTimeStep;
}

return PredictionLocation;


While loop is same logic from UCharacterComponent::CalcVelocity; Considering the capsule has zero acceleration and 0.0f < Velocity.Size() <= MaxSpeed, you can get those equation.

How is it going? :stuck_out_tongue:

I have a small update because Iā€™m too lazy and my main laptop has been broken :slight_smile:

Added:

  • Smooth blending between four directional movement
  • Orientation Warping
  • Lean
  • Turn in place on 90 and 180 degrees

Looks good!

New video coming soon :slight_smile:

Hyped! :slight_smile: Love your content.
Iā€™m doing a small animation project myself. Would love to make in place start/stop based on distance matching, but there is no tutorials nor materials to get startedā€¦ :frowning:

[quote=ā€œAngeIV, post:161, topic:122622ā€]

Hyped! :slight_smile: Love your content.
Iā€™m doing a small animation project myself. Would love to make in place start/stop based on distance matching, but there is no tutorials nor materials to get startedā€¦ :frowning:Resident Evil In Unreal Engine 4 - Demo and Download link - YouTube

Thank You!
This project what you have sent is impressive! Are you using ragdoll?

The start/stop animations based on distance matching are very easy to set. You can use paragonā€™s free assets for your work and this video: https://www.youtube.com/watch?v=1UOYā€¦ture=emb_title
It is very helpful.

yeahā€¦ ragdoll and force applied depending on the hit component :wink:
Thank you. :slight_smile:
As for distance matching thereā€™s no good source that actually shows you how to set it up. But if you throw some nodes names and general method to read about Iā€™m more than willing to give it a try. Iā€™ve seen this video multiple times, but maybe I missed it somehow? They say a lot on what they doā€¦ not how they do it :smiley:

By the way you can check my setup of anim BPā€¦ Link for download in the description

How they do it essentially boils down to physics calculations.

Basically, you know everything you need. The mass, the velocity, the friction, etc.
and you use the same calculations used by the engine to figure out a distance.

This value is then found inside the animation curves, where the curved is used one way or another to affect changes to the animation.

For a stop motion example of that: you have a mass, a current speed and a friction so you know you will stop in x meters.
The stop animation can therefore be told to start at Y frame which makes it feel like you are stopping in a timely manner.
Obviously when the aniamation ā€œstartsā€ is an approximation decided by artists or a readout of the distance the actor actually traveled (which is present in the root motion animation).
(less obviously this animation can have some amount of root motion and take over the physics so that foot sliding is completely gone).

if you take to CPP and create physic prediction blueprint callable functions you can make the 2 or 3 you really need (can be done in blueprint too, just like foot IK).
The ones to focus on are the start/stop, because it is used everywhere, and the jump apex / landing.

The animations are what is hard to make.
If you do go through and make them, make sure not to waste time on the mannequinā€¦ if you produce for your actual final mesh, you can always retarget to the mannequin - going the other way around has poor results because of the twist bones and lack of corrective morphs.
If you can mocap yourself the process gets much easier/faster and more accurate.

2 Likes

Thank You @AngeIV and [USER=ā€œ3140864ā€]MostHost LA[/USER].

@AngeIV
I still have presetation file about distance matching. I can send You if You want.