Play animation while moving

Hi Justin, I added a 'Body' weapon to the character. I found that clicking the mouse when the character is moving will play the 'moving attack' animation, and clicking the mouse when the character is not moving will play the 'standing attack' animation. I think the ‘standing attack’ and ‘moving attack’ animations are the same animation, but 'standing attack' disables the lower body.

I have two questions.
1. How to prohibit attacks when the character moves?
2. Can I make the character play 'standing attack' animation instead of 'moving attack' animation by pressing the mouse while moving?
 

Justin

Administrator
Staff member
1. On the Use Animator Audio State you can specify that a particular state should not play when the character is moving:

1581940353726.png

2. Yes - this can be done on the animator side of things. When the particular use state index is called you can play an animation that uses root motion. This will then stop the character from moving and play the non-moving attack animation.
 
1. On the Use Animator Audio State you can specify that a particular state should not play when the character is moving:

View attachment 2342

2. Yes - this can be done on the animator side of things. When the particular use state index is called you can play an animation that uses root motion. This will then stop the character from moving and play the non-moving attack animation.

2.How do I modify root motion in animator based on state index?

The 'Apply Root Motion' under Animator on the character only allows code modification. I opened Animator and couldn't find a place to modify ‘Root Motion’. I checked the animation and found the 'Root Motion Node' option but it didn't work.
 

Sarah

Administrator
Staff member
Root Motion is specified in the animation itself, not in the animator. If you look at the demo animations under Body, all of the "heavy" attack animations are the standing attacks and the Root Transform Position (XZ) is checked to bake into pose.

All of the standing attacks are on the full body layer so that all other layers get overridden if that animation plays. To make the standing attack play no matter what you need to make sure the transitions allow for it. In the demo controller the full body attacks have a conditon of moving = false, so those only play when he is not moving. If you remove that condition it would always go to those attacks moving or not.

Are you using the demo controller? I highly recommend using that as a guide and creating your own from scratch to double check all the transitions. Also make sure you remove the moving attacks in the animator just to clean it up :)
 
Root Motion is specified in the animation itself, not in the animator. If you look at the demo animations under Body, all of the "heavy" attack animations are the standing attacks and the Root Transform Position (XZ) is checked to bake into pose.

All of the standing attacks are on the full body layer so that all other layers get overridden if that animation plays. To make the standing attack play no matter what you need to make sure the transitions allow for it. In the demo controller the full body attacks have a conditon of moving = false, so those only play when he is not moving. If you remove that condition it would always go to those attacks moving or not.

Are you using the demo controller? I highly recommend using that as a guide and creating your own from scratch to double check all the transitions. Also make sure you remove the moving attacks in the animator just to clean it up :)
Yes, I use the demo controller, I understand now, thank you Sarah.
 
Top