I need to know the distance and direction (vector I guess) covered by an animation.
I see this has been covered before in terms of adjusting the distance, adding keyframes, UE5 with morphing and so on. Those don’t help me in this instance. I just need to know the end point releative to the start point of the root bone for a character animation. The engine clearly knows this but I can’t find a way of extracting it without playing the animation first and recording the transforms.
One thing you could do: create a Vector variable, SET it by grabbing your static mesh component->GetTransformAttribute → SET the vector (make sure your bone name matches your root on your skeletal mesh EXACTLY). Do that right before animation starts.
THEN: at the END of the animation grab the static mesh component again, and then subtract your variable from earlier away from the new position. Use Get ABS (absolute) if you want only positive values. That vector can be split into X,Y, Z float values as well if you right click it. Hope that helps!
Edit: To get the direction, use a “LookAt” node, plug your RootStart vector in the top and end location into the bottom!
Edit2: I think I may have misunderstood the question. This would be a way to get the distance and direction in runtime. @FrankieV’s answer below would be a better path if you need to get the distance in the editor, without running the game
If you need it before playing the animation…
Do you expect the distance to vary? Is that why you can’t use a static value?
What kind of animation is it? What’s the goal or purpose of measuring it?
Distance is affected by a lot of things apart from the animation.
If in root motion you can evaluate distance the root bone travels as RM is event driven so the distanced travelled can be evaluated based on velocity over time. Animation data wise distance is not fixed as per unit travelled. For the math there is a project example around here some place demonstrating motion matching which I assume for now includes the math to interpret time to distance travelled.
Inplace animation on the other hand is reactive as to the needed state change and is pure visual in nature. Animation action is preformed by the movement component which is what is actually used to control all movement requirements. It’s a puppet in a box so things like gravity is applied as a condition where the player is in a constant state of falling. The Movement Component also tracks the forward vector by adding a default collision capsule with an arrow which indicates the forward direction the MC moves.
Th MC should give you an idea as to velocity > distance as for example Character Monument Walk > Max Walk Speed = 600.00 cm/s. To match the reactive animation to the max speed you could change the base rate (speed) of the animation.
Thanks for the reply. Although I need it before the animation plays, this is the sort of thing I’ll have to fall back on and just calculate distances in the background.
Thanks for your reply. Yes, it’s a bit of a messy issue. I realise the mutitude of things affecting distance could create issues so in this case the blends don’t exist and root motion is used. Then you may ask why not just use a static value? That’s a good point and maybe I should, but I’m thinking ahead to the stage when I’ll need many animations and I don’t want to be checking their root motion distances in blender (or similar) and importing them manually. I was hoping Unreal would just be able to tell me the distance covered by the root bone excluding any other influences.
Well this is the root of the problem (pun intended) as animation is data in general and up to the user to decide what the data represents. Distance over time for example is like speed signs on the highway that say 60 mph you can use that as a known value and figure out distance. This applies only to root motion of course as distance is set using inplace as determined by the movement component.
Problem 2 is RM data is not an absolute so the path to take depends on what it is that the data needs to do as a constant and then follow a set of rules that would be the same for all takes and then apply the data in UE5 as to what the data represents more so as to distance.
As I noted this is a function of motion matching where math is used to determine distance and there is currently a topic that covers motion mating in more detail where you could get you answers as to distance and as to the requirements of the RM data sets.
As mention a good solution is to snag the distance during play but as you say will not work for you for reason you have not stated. The other option is you don’t need to play the animation but rather extract the start and end pose of the cycle and convert units to what ever distance factor you require.
The other option, as you mentioned, would be to import the animation into Blender and use the app as a proxy to determine distance setting world scale to 1 unit = 1 cm.
The other option is in how the RM data could be formatted to included distance based on units or fixing a rule during authoring of the data that it follows unreal rule that 1 UE unit = 1 cm.
Sorry if things are still foggy, welcome to my world, but I suggested looking into motion matching as distance matching is one of it’s function as it relates to the use of root motion which I’m still foggy about due to the lack of usable information.
I tried to find the topic but unable to find it off hand so if someone knows the link please be kind and post it?
The main problem is being able to extract the root motion as curves as it’s applied to the root bone.
Many moons ago someone wrote a plugin that did this job as UE4 does not support curve extraction.
As far as I know UE5 still does not support the ability to extract the curves and the plug in is no longer for sale as it can be assumed that it’s no longer updated.
It’s a shame that curve extraction is not a basic feature (as far as I know)