1
\$\begingroup\$

I am trying to create a cover system for my 3rd person shooter game in Unity.

My implementation is a basic one :

On Player enter Trigger Player move to preset cover position Player play Enter Cover animation (eg: dash to cover) 

This is fine without root motion enabled, when it is enabled (so the movements look natural), instead of dash & stop behind the cover, the Player will dash and stuck himself inside the cover (due to root motion). So I am curious, what is a good way to do the animation for cover system?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

If you're relying entirely on root motion to move your character's correctly, you have to ensure the character is in a precise spot before triggering the animation -- if your "hide in cover" animation displaces a character's center to the left two feet, their center must be two feet (plus their radius) away from the cover to start with. Otherwise they'll clip into the local geometry.

The simple option is to just adjust the displacement in the animation and/or adjust the starting position in the world where you trigger the animation (your "preset cover position").

If you rely only on root motion, though, you have to do a lot of precise positioning of the "cover positions" and such, and that can be tedious to maintain. Your distances must all be fixed according to the distances in the animation, and that constrains your options for actual environment art.

Instead, you can disable root motion temporarily to "line the character up" by interpolating their rotation and position. If they're far away, use a root-motion based locomotion action to get them within a reasonable tolerance, and then interpolate them with root motion disabled to position them precisely, and then re-engage root motion to do the "hide."

You can still play the same animations without root motion -- up to a certain threshold, the player won't notice some slight footsliding or misalignment of the animation versus the ground, especially if it happens quickly or there's a camera cut to help mask it.

\$\endgroup\$
1
  • \$\begingroup\$ A mix of locomotion to a correctly-offset animation entry point, and blending-out error in the offset over the course of the animation as described above is what I've seen used in the past too. One additional layer that can help (for the player character in particular) is applying IK to the feet (or points of contact, more generally) so they don't slide as the error is blended out. If they land in a slightly-offset position, they lock into that offset until the next step lets them snap to a smaller offset. A quick shuffle at the end of the animation lets them land in their final animated pose. \$\endgroup\$ Commented Aug 16, 2018 at 17:06

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.