Mecanim state tag

Hi all

Is there any way to get (raed/write) state tag ? (I mean script)

see picture

1 Answer

1

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

thanks scarletshark

–

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.][1] [1]: https://www.youtube.com/watch?v=ezAPpViLs2Q

–