- Home /
This question was
closed Jun 20, 2020 at 01:10 PM by
WhisperXD for the following reason:
The question is answered, right answer was accepted
Question by
WhisperXD · Jun 20, 2020 at 12:13 PM ·
namemotionstate-machineinfo
StateMachineBehaviour get name ??
how can i get this name ?? and put to string ??
get-name.png
(21.7 kB)
Comment
Best Answer
Answer by Hellium · Jun 20, 2020 at 12:40 PM
For what reason exactly do you want this string? The OnStateXXX
methods have a AnimatorStateInfo
as second parameter. This data structure contains the shortNameHash. If you want to do some comparison with another state name for instance, you can do
if(stateInfo.shortNameHash == Animator.StringToHash("yourString"))
Knowing what you exactly want to do might help giving you an appropriate answer.
Answer by LeFlop2001 · Jun 20, 2020 at 12:29 PM
theres no way to get the name directly but you can get it by comparing it to a list of names you think it has by using the animator function cA.GetCurrentAnimatorStateInfo(i).IsName("string");