0
\$\begingroup\$

I am working on an endless running 3d game. I have 2 characters. One of them is a small kid and another one is a security guard. Both characters and animations are exported as separate FBXs.

The scene is something similar to the situation in Subway Surfer, where the cop picks up the character. See first few seconds - https://www.youtube.com/watch?v=FdxgHMh0QEc

For this we animated both the characters in a single file in 3DS Max. In this file one character has to pick other character by his leg.

Now how should I proceed so that both the animations play in sync when shown in the game. What would be the best approach to sync different characters in Unity when using different files ? Or should I export a single file containing both the characters and animations and use it just for this scene?

Any help would be really appreciated. Thanks in advance.

\$\endgroup\$
3
  • \$\begingroup\$ Could you temporarily parent the kid's root bone to the cop's hand bone? \$\endgroup\$
    – Jon
    Mar 17, 2016 at 6:56
  • \$\begingroup\$ have you seen this Unity Animation Blending tutorial? youtube.com/watch?v=65ns7uikvzc \$\endgroup\$ Mar 17, 2016 at 10:21
  • \$\begingroup\$ Logically, when captured, the kid and guard should be under a common parent object with animation (at least temporarily) which will animate them both. That being said, you should figure out a way of having 2 child animations end in a way to seemlessly start the parent animation. \$\endgroup\$ Mar 17, 2016 at 10:29

1 Answer 1

1
\$\begingroup\$

This is a bit old, but still relevant.

The best way of managing animation in Unity is to always consider each "actors" as their own. In this case, consider the cop as a separate entity than the kid or whatever that get grabbed by the feet.

The best way of doing this is by doing it when using 3dsMax is through the following steps.

Step One, make sure you're using 2 animation layers when animating. It's something that can be done with both CAT and Biped, but slightly different in terms of how it's done. The Layer 1 act as the "Movement" on the X and Z axis. (If Y is upward) The Layer 2 act as the Rotation/Limb layer.

Step two, on layer 1, you place the character at their relative position as to what it would be in the game. On layer 2, you manage the body's movements (Like the cop crouching a big to grab the kid's leg or something). Ideally, make sure that one of the 2 characters is in the center/origine of the world (like the cop) and take note of the position of the kid before he get taken up by the leg. Once the animation is done, save a copy (in case you need to access it again). delete the layer 1. This is will bring both the cop and kid at the X & Z origin.(They will both be in the center of the 3dsMax scene.)

Step three, you export both the Cops and the Kid (and their relative bones/armature) in separate FBX file. Each should be separate entities in Unity.

Step four, in Unity, create each their own animator with the relevant states.

Step five, when the cop has to grab the kid's leg, adjust the positions (and movement) in Unity so that the same distance and orientation (as used in the layer 1 in 3dsMax which I suggested to take note of). This requires that you program the animation in synch with the in-game movement. (In other words, movement of the legs are based on the movement in the world that translate into the animator parameter.) then, when the cop tries to grab the kid and if it's successful, a call is sent to the kid's animator to start the "get grabbed" animation. This part has to be one in multiple animations part : Cop has the part where it tries to grab. Then it has the 2 possibilities of successfully grab or failing to grab. Then it has the lift up or the recover animation (based on the results) and then whatever you want. The kid might have an evade (if close to get grabbed) and a "being grabbed" (that start at the same time as when you start the cop's "Successful Grab" animation) and a "Grabbed" for when the cop is holding the kid's leg.

the easiest way of managing this is to always consider that there's 1 master script and 1 subordinate scripts depending on who got the upper hand. It also important to understand how to make both script communicate together efficiently so that calls and parameters can easily be transmitted from one to the other.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .