• Yves "Jack" Albuquerque

Basic: Match Target

I use root motion to move my characters. In that way we avoid the terrible sliding effect that occurs when a character animation don't match a character movement.

Sometimes, however, we need to turn it off in order to play animation maintaining our root where it is. There's several cases that this is used. The most usual case scenario is during aerial movements since the trajectory of our character don't change according to his movement (on most cases).

However, a third case scenario exist. Maybe you want both things. So you can have some root motion but, at the same time, you want a specific result during this action. This specific result can be a specific root position/rotation at the middle of the animation, or a position for an specific part of your character.

Too abstract? Let me give you some examples.

Suppose that you are creating a climbing system. Your character is holding a ledge, he makes the jump movement from a ledge to another and, at the end of this aerial movement part, he is holding the other ledge. What if the other ledge position is not at a fixed distance?

Using root motion you need an animation for each possible direction and distance what doesn't make any sense.

Without root motion, you will need to compensate the entire movement using offsets related to the entire jump-to-a-new-ledge timeline. A lot of effort to a simple movement.

The way to go here is to detect when the player leaves the first ledge, lerp his position when executing the aerial part of the animation, and, match his hand with the next ledge exactly at the end of the aerial animation part.

Unity Animator system give us a system for that using targets. You can specify a target (Hand, Foot, Root or Body) and track it`s position/rotation or, use a method called "MatchTarget" to do that.

MatchTarget executes only the base layer and on the current animation state. You should pass the normalized start time and end time.

I did another example using a Jump. You can download the code used on this example here.

#Unity #Animator #Animation #Mecanim

586 visualizações0 comentário

Posts recentes

Ver tudo