- Home /
Can I use the animation component with a mecanim rigged character?
Is it possible to use the animation component (not animator) with a character that has a mecanim humanoid rig? I haven't been able to figure this one out yet, but I would love to, because I can't seem to wrap my head around mecanim. I can't get characters to grapple with each other using mecanim, but I can with the animation component and my scripts.
So, is it possible?
Answer by Demonicdaron · Aug 08, 2015 at 10:57 AM
It would be easier to answer if you were a bit more specific on what you intend to do with the animation component, but in broad terms, you can get some information about the current animation being played using the AnimatorStateInfo or AnimatorClipInfo. However, to control the animations you have to use the mecanim way, so use the parameters/states and all the other stuff.
This doesn't mean that you must use mecanim! you can still use the animation component and manage the animations yourself, the humanoid type shouldnt give you any issue.
What I'm trying to do is trigger an animation on collision. I have a test dummy which I called TD. So, I want to have the Player go to the test dummy and play the attack animation on an ontriggerenter or oncollisionenter and stop playing when the player moves away from it. I haven't seen anything like this documented. I don't want to overload the mecanim controller with dozens of animations for different objects. So, I was thinking I could trigger the animation from the animation component ins$$anonymous$$d. I'm just now reading about layers and such and trying to wrap my head more about $$anonymous$$ecanim at the moment. I'm co$$anonymous$$g from a more legacy way of animating.
Thank you!! I finally got it. $$anonymous$$odified a bit of your code there and boop... It works. Thanks so very much!
Answer by Demonicdaron · Aug 10, 2015 at 09:50 PM
If you just want to trigger the animation when colliding, can't you add a trigger collider to the dummy, add a script to the dummy where you have:
void OnTriggerEnter(collider other) {
if (other.CompareTag("Player")) {
yourAnimator.SetTrigger/SetBool/SetFloat("YourParameter", yourValue);
}
}
Answer by Demonicdaron · Aug 10, 2015 at 09:50 PM
If you just want to trigger the animation when colliding, can't you add a trigger collider to the dummy, add a script to the dummy where you have:
void OnTriggerEnter(collider other) {
if (other.CompareTag("Player")) {
yourAnimator.SetTrigger/SetBool/SetFloat("YourParameter", yourValue);
}
}
This is what I did only slightly modified, but it works swim$$anonymous$$gly. So glad I can continue on to the next steps of my project! Thank you so much for your insight and input.
Your answer
Follow this Question
Related Questions
Can Mecanim & Legacy animation be used on the same character? 1 Answer
Is it possible to use a mecanim animation with the legacy Animation component? 0 Answers
Why do legacy & humanoid animations look different on the same character? 1 Answer
Animation must be marked as Legacy, however there is no way to do so. 1 Answer
Use Legacy animation in Mecanim 1 Answer