1
\$\begingroup\$

I'm writing little fps game in Unity 5.3.5. So, I've got my gun object and two animations, idle and shot. I've got transition from idle to shot with trigger condition and "Has Exit Time" unchecked. In the idle animation after few seconds gun do some cowboy-style spinning. Problem is, when I fire my trigger during the spin, shot animation starts exactly from point where idle animation was interrupted, which causes shooting to the sky or to the ground.

I know i can make no transitions and do everything from code, and reset every animation to start position before playing another, but is this elegant way to do such a thing? Are there any good practices someone could share with me?

\$\endgroup\$
  • \$\begingroup\$ Do you use Blend Trees? By the way, it's very uncommon for FPS games to have the fire direction affected by the rotation of the weapon model. \$\endgroup\$ – Philipp Aug 18 '16 at 11:00
  • \$\begingroup\$ No, I'm not using Blend Trees. Actually never heard of them, gonna check them out. direction of bullet is not affected, it works fine, only weapon animation shows that i'm shooting myself :P Do you think Blend Trees are something that could help in my situation? \$\endgroup\$ – dargemir Aug 18 '16 at 11:08
  • \$\begingroup\$ Does your shoot animation start by having the gun pointing, or lifting the arm up in preparation to shoot? \$\endgroup\$ – Peter Morris Aug 18 '16 at 11:19
  • \$\begingroup\$ I don't have an arm, just gun. Every animation's first and last frame brings model to situation, where all transform parameters are set to 0. For example, when i shot gun is in it's default position, after 0.1 sec barrel jumps up a bit, and then after 0.9 sec if comes back to the default position. For now all animations are just one-dimension rotations. The problem is, when I interrupt one animation, the "default" state is no more all 0's. Maybe problem is that i made my animations in unity, not in my modeling program. \$\endgroup\$ – dargemir Aug 18 '16 at 11:30
1
\$\begingroup\$

Ok, I think I figured this out. Disabling root motion made my gun act properly. I'm surprised, because i thought that if I would turn this option off, gun will stuck in his base position on map, like global 0,0,0. Surprisingly, it's transform is properly inherited from parent object.

| improve this answer | |
\$\endgroup\$
0
\$\begingroup\$

Reduce transition duration of the intended transition.

enter image description here

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ It's not helpful. I'm recording my animations by changing object transform proporties in keyframes in unity animation editor. If in the middle of Idle animation gun is rotated by 90 degrees and I'll interrupt this animation, another will start with this rotation as a base state. \$\endgroup\$ – dargemir Aug 18 '16 at 11:41
  • \$\begingroup\$ @dargemir What's the initial rotation of gun on Shoot state? \$\endgroup\$ – Sourav Paul Aug 18 '16 at 11:59
  • \$\begingroup\$ Every animations start and ends with rotation (0, 0, 0); \$\endgroup\$ – dargemir Aug 18 '16 at 12:19
  • \$\begingroup\$ @dargemir What happens when you reduce transition duration? \$\endgroup\$ – Sourav Paul Aug 18 '16 at 12:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.