- Home /
Mecanim state tag
Hi all
Is there any way to get (raed/write) state tag ? (I mean script)
see picture
Answer by scarletshark · May 06, 2015 at 08:37 PM
You can GET (read) the tag, but not set it. (0 is the Base Layer. You must change if your animation is on a different layer).
Animator animator;
AnimatorStateInfo animatorInfo;
void Update () {
animatorInfo = animator.GetCurrentAnimatorStateInfo(0);
if(animatorInfo.tagHash == Animator.StringToHash("myTag")){
// do something
}
}
--OR--
Animator animator;
AnimatorStateInfo animatorInfo;
void Update () {
animatorInfo = animator.GetCurrentAnimatorStateInfo(0);
if(animatorInfo.IsTag("myTag")){
// do something
}
}
Source: API Docs for AnimatorStateInfo
Did it work for you? If so, please accept my answer :) Thank you.
I have got no idea What should I do to accept your answer
See the thumbs-up and thumbs-down next to my answer? There should be a check mark there. It's also worth watching the tutorial video.
Your answer
Follow this Question
Related Questions
Use mecanim for FPS animations? 1 Answer
Mecanim problem with setting speed 0 Answers
Mecanim control animation frames via script? 2 Answers
Mecanim How Animate Bone a Ball Using Humanoid? 0 Answers
Is there a way to use physics to keep a character from clipping through itself during an animation? 0 Answers